Looks like FileDescriptorEvent
blocks other vibe.d I/O
This code
/+ dub.json:
{
"name": "test",
"dependencies": {
"vibe-d:core": "0.7.29"
}
}
+/
import std.stdio;
import std.socket;
import std.datetime;
import vibe.core.core;
void main() {
runTask({
writeln("start task 1");
yield();
writeFile("dummy.txt", cast(immutable ubyte[]) "1234567890");
writeln("end task 1");
exitEventLoop();
});
runTask({
writeln("start task 2");
auto pair = socketPair();
auto evt = createFileDescriptorEvent(pair[1].handle, FileDescriptorEvent.Trigger.any);
//destroy(evt);
writeln("end task 2");
});
runEventLoop();
}
prints
start task 1
start task 2
end task 2
end never exits the event loop.
Looks like Task 1 hangs on writeFile()
.
If to uncomment destroy(evt)
then code works as expected.