Skip to content

Commit f5bd52d

Browse files
committed
Merge pull request #728 from Safety0ff/fix11454
Fix issue 11519 - race in core.thread unit test
2 parents 9ee8ff1 + 005fae0 commit f5bd52d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/core/thread.d

+8-3
Original file line numberDiff line numberDiff line change
@@ -2668,21 +2668,26 @@ unittest
26682668
import core.sync.semaphore;
26692669

26702670
shared bool inCriticalRegion;
2671-
auto sem = new Semaphore();
2671+
auto sema = new Semaphore(),
2672+
semb = new Semaphore();
26722673

26732674
auto thr = new Thread(
26742675
{
26752676
thread_enterCriticalRegion();
26762677
inCriticalRegion = true;
2677-
sem.notify();
2678+
sema.notify();
2679+
semb.wait();
2680+
26782681
Thread.sleep(dur!"msecs"(1));
26792682
inCriticalRegion = false;
26802683
thread_exitCriticalRegion();
26812684
});
26822685
thr.start();
26832686

2684-
sem.wait();
2687+
sema.wait();
26852688
assert(inCriticalRegion);
2689+
semb.notify();
2690+
26862691
thread_suspendAll();
26872692
assert(!inCriticalRegion);
26882693
thread_resumeAll();

0 commit comments

Comments
 (0)