From 100dfc30eec09a07f9ec2def2f8265fb6ac3e15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 20 Jul 2017 16:10:18 +0200 Subject: [PATCH] Add test that triggers the former bug in ThreadLocalWaiter.emit() and ensures FIFO emit order. --- source/vibe/core/sync.d | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source/vibe/core/sync.d b/source/vibe/core/sync.d index d7c15c8..3220e5f 100644 --- a/source/vibe/core/sync.d +++ b/source/vibe/core/sync.d @@ -802,6 +802,30 @@ unittest { runEventLoop(); } +unittest { + import vibe.core.core : exitEventLoop, runEventLoop, runTask, sleep; + + LocalManualEvent l = createManualEvent(); + + Task t2; + runTask({ + l.wait(); + t2.interrupt(); + sleep(20.msecs); + exitEventLoop(); + }); + t2 = runTask({ + try { + l.wait(); + assert(false, "Shouldn't reach this."); + } catch (InterruptException e) {} + }); + runTask({ + l.emit(); + }); + runEventLoop(); +} + /** A manually triggered multi threaded cross-task event.