Skip to content

Commit

Permalink
Merge pull request #2773 from 9rnsr/fix13783
Browse files Browse the repository at this point in the history
Supplemental fix for issue 13783 in std.parallelism
  • Loading branch information
H. S. Teoh committed Dec 2, 2014
2 parents 30de4c1 + 638cede commit ca2171d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions std/parallelism.d
Expand Up @@ -204,20 +204,23 @@ else
without wrapping it. If I didn't wrap it, casts would be required
basically everywhere.
*/
private void atomicSetUbyte(ref ubyte stuff, ubyte newVal)
private void atomicSetUbyte(T)(ref T stuff, T newVal)
if (__traits(isIntegral, T) && is(T : ubyte))
{
//core.atomic.cas(cast(shared) &stuff, stuff, newVal);
atomicStore(*(cast(shared) &stuff), newVal);
}

private ubyte atomicReadUbyte(ref ubyte val)
private ubyte atomicReadUbyte(T)(ref T val)
if (__traits(isIntegral, T) && is(T : ubyte))
{
return atomicLoad(*(cast(shared) &val));
}

// This gets rid of the need for a lot of annoying casts in other parts of the
// code, when enums are involved.
private bool atomicCasUbyte(ref ubyte stuff, ubyte testVal, ubyte newVal)
private bool atomicCasUbyte(T)(ref T stuff, T testVal, T newVal)
if (__traits(isIntegral, T) && is(T : ubyte))
{
return core.atomic.cas(cast(shared) &stuff, testVal, newVal);
}
Expand Down

0 comments on commit ca2171d

Please sign in to comment.