From f6736d13ab4c21a37f4869d3aff5404e3b262067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 20 Jul 2017 16:14:47 +0200 Subject: [PATCH] Add test that reproduces the LocalManualEvent copy bug. --- source/vibe/core/sync.d | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/vibe/core/sync.d b/source/vibe/core/sync.d index 3220e5f..7f5edcc 100644 --- a/source/vibe/core/sync.d +++ b/source/vibe/core/sync.d @@ -802,7 +802,7 @@ unittest { runEventLoop(); } -unittest { +unittest { // ensure that cancelled waiters are properly handled and that a FIFO order is implemented import vibe.core.core : exitEventLoop, runEventLoop, runTask, sleep; LocalManualEvent l = createManualEvent(); @@ -826,6 +826,22 @@ unittest { runEventLoop(); } +unittest { // ensure that LocalManualEvent behaves correctly after being copied + import vibe.core.core : exitEventLoop, runEventLoop, runTask, sleep; + + LocalManualEvent l = createManualEvent(); + runTask({ + auto lc = l; + sleep(100.msecs); + lc.emit(); + }); + runTask({ + assert(l.wait(1.seconds, l.emitCount)); + exitEventLoop(); + }); + runEventLoop(); +} + /** A manually triggered multi threaded cross-task event.