Add test for #157.
This commit is contained in:
parent
79bb21c6a3
commit
19ea38fc72
29
tests/issue-157-consume-closed-channel.d
Normal file
29
tests/issue-157-consume-closed-channel.d
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/+ dub.sdl:
|
||||||
|
name "tests"
|
||||||
|
dependency "vibe-core" path=".."
|
||||||
|
+/
|
||||||
|
module tests;
|
||||||
|
|
||||||
|
import vibe.core.channel;
|
||||||
|
import vibe.core.core;
|
||||||
|
import core.time;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
auto ch = createChannel!int();
|
||||||
|
|
||||||
|
auto p = runTask({
|
||||||
|
sleep(1.seconds);
|
||||||
|
ch.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto c = runTask({
|
||||||
|
while (!ch.empty) {
|
||||||
|
try ch.consumeOne();
|
||||||
|
catch (Exception e) assert(false, e.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
p.join();
|
||||||
|
c.join();
|
||||||
|
}
|
Loading…
Reference in a new issue