Fir a deadlock when exiting on MacOS (GL backend)

Closes #2159

There was two issues:
1) Fence::wait would return prematurely when the the timeout was
   set to WAIT_FOREVER.

2) (At least) when running from the command line, events were not
   read from the main queue. Instead we have to use NSRunLoop instead
   of NSApplication APIs.
This commit is contained in:
Mathias Agopian
2020-02-26 15:56:51 -08:00
committed by Mathias Agopian
parent 108dae11e9
commit 4e9cf8ac02
2 changed files with 2 additions and 8 deletions

View File

@@ -147,13 +147,7 @@ bool PlatformCocoaGL::pumpEvents() noexcept {
if (![NSThread isMainThread]) {
return false;
}
while (true) {
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event == nil) {
break;
}
[NSApp sendEvent:event];
}
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantPast]];
return true;
}

View File

@@ -99,7 +99,7 @@ FenceStatus FFence::wait(Mode mode, uint64_t timeout) noexcept {
}
engine.pumpPlatformEvents();
const auto elapsed = std::chrono::system_clock::now() - startTime;
if (elapsed >= ns(timeout)) {
if (timeout != Fence::FENCE_WAIT_FOR_EVER && elapsed >= ns(timeout)) {
break;
}
}