Merge pull request #67 from vibe-d/issue_66_yield_exit_eventloop

Don't exit event loop prematurely.
This commit is contained in:
Sönke Ludwig 2018-03-07 10:39:55 +01:00 committed by GitHub
commit a1a0d52fe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View file

@ -1140,8 +1140,8 @@ package(vibe) void performIdleProcessing()
if (again) {
auto er = eventDriver.core.processEvents(0.seconds);
if (er.among!(ExitReason.exited, ExitReason.outOfWaiters)) {
logDebug("Setting exit flag due to driver signalling exit");
if (er.among!(ExitReason.exited, ExitReason.outOfWaiters) && s_scheduler.scheduledTaskCount == 0) {
logDebug("Setting exit flag due to driver signalling exit: %s", er);
s_exitEventLoop = true;
return;
}

View file

@ -0,0 +1,19 @@
/+ dub.sdl:
name "tests"
dependency "vibe-core" path=".."
+/
module tests;
import vibe.core.core;
void main()
{
bool visited = false;
runTask({
yield();
visited = true;
exitEventLoop();
});
runApplication();
assert(visited);
}