Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Use atomic ops in host test
Browse files Browse the repository at this point in the history
  • Loading branch information
radcapricorn committed Feb 10, 2014
1 parent 14fa404 commit 92ef80b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/shared/src/plugin.d
@@ -1,10 +1,10 @@
import core.thread, core.memory;
import core.thread, core.memory, core.atomic;

shared uint gctor, gdtor, tctor, tdtor;
shared static this() { ++gctor; }
shared static ~this() { ++gdtor; }
static this() { ++tctor; }
static ~this() { ++tdtor; }
shared static this() { atomicOp!"+="(gctor, 1); }
shared static ~this() { atomicOp!"+="(gdtor, 1); }
static this() { atomicOp!"+="(tctor, 1); }
static ~this() { atomicOp!"+="(tdtor, 1); }

Thread t;

Expand All @@ -15,10 +15,10 @@ extern(C) int runTests()
{
try
{
assert(gctor == 1);
assert(gdtor == 0);
assert(tctor >= 1);
assert(tdtor >= 0);
assert(atomicLoad!(MemoryOrder.acq)(gctor) == 1);
assert(atomicLoad!(MemoryOrder.acq)(gdtor) == 0);
assert(atomicLoad!(MemoryOrder.acq)(tctor) >= 1);
assert(atomicLoad!(MemoryOrder.acq)(tdtor) >= 0);
// test some runtime functionality
launchThread();
GC.collect();
Expand Down

0 comments on commit 92ef80b

Please sign in to comment.