Add tests from vibe-d:core.
This commit is contained in:
parent
99bc332a81
commit
5a8d5a2fea
7 changed files with 354 additions and 0 deletions
58
tests/vibe.core.concurrency.1408.d
Normal file
58
tests/vibe.core.concurrency.1408.d
Normal file
|
@ -0,0 +1,58 @@
|
|||
/+ dub.sdl:
|
||||
name "tests"
|
||||
description "std.concurrency integration issue"
|
||||
dependency "vibe-core" path="../"
|
||||
versions "VibeDefaultMain"
|
||||
+/
|
||||
module test;
|
||||
|
||||
import vibe.core.concurrency;
|
||||
import vibe.core.core;
|
||||
import vibe.core.log;
|
||||
import core.time : msecs;
|
||||
import std.functional : toDelegate;
|
||||
|
||||
void test()
|
||||
{
|
||||
auto t = runTask({
|
||||
bool gotit;
|
||||
receive((int i) { assert(i == 10); gotit = true; });
|
||||
assert(gotit);
|
||||
sleep(10.msecs);
|
||||
});
|
||||
|
||||
t.tid.send(10);
|
||||
t.tid.send(11); // never received
|
||||
t.join();
|
||||
|
||||
// ensure that recycled fibers will get a clean message queue
|
||||
auto t2 = runTask({
|
||||
bool gotit;
|
||||
receive((int i) { assert(i == 12); gotit = true; });
|
||||
assert(gotit);
|
||||
});
|
||||
t2.tid.send(12);
|
||||
t2.join();
|
||||
|
||||
// test worker tasks
|
||||
auto t3 = runWorkerTaskH({
|
||||
bool gotit;
|
||||
receive((int i) { assert(i == 13); gotit = true; });
|
||||
assert(gotit);
|
||||
});
|
||||
|
||||
t3.tid.send(13);
|
||||
sleep(10.msecs);
|
||||
|
||||
logInfo("Success.");
|
||||
|
||||
exitEventLoop(true);
|
||||
}
|
||||
|
||||
shared static this()
|
||||
{
|
||||
setLogFormat(FileLogger.Format.threadTime, FileLogger.Format.threadTime);
|
||||
runTask(toDelegate(&test));
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue