mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Improved CPU efficiency of MessageManager::runDispatchLoopUntil() on OSX
This commit is contained in:
parent
9fe83c18bd
commit
60cbac6a6d
1 changed files with 11 additions and 10 deletions
|
|
@ -389,18 +389,19 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
|
|||
{
|
||||
JUCE_AUTORELEASEPOOL
|
||||
{
|
||||
CFRunLoopRunInMode (kCFRunLoopDefaultMode, 0.001, true);
|
||||
auto msRemaining = endTime - Time::currentTimeMillis();
|
||||
|
||||
NSEvent* e = [NSApp nextEventMatchingMask: NSEventMaskAny
|
||||
untilDate: [NSDate dateWithTimeIntervalSinceNow: 0.001]
|
||||
inMode: NSDefaultRunLoopMode
|
||||
dequeue: YES];
|
||||
|
||||
if (e != nil && (isEventBlockedByModalComps == nullptr || ! (*isEventBlockedByModalComps) (e)))
|
||||
[NSApp sendEvent: e];
|
||||
|
||||
if (Time::currentTimeMillis() >= endTime)
|
||||
if (msRemaining <= 0)
|
||||
break;
|
||||
|
||||
CFRunLoopRunInMode (kCFRunLoopDefaultMode, jmin (1.0, msRemaining * 0.001), true);
|
||||
|
||||
if (NSEvent* e = [NSApp nextEventMatchingMask: NSEventMaskAny
|
||||
untilDate: [NSDate dateWithTimeIntervalSinceNow: 0.001]
|
||||
inMode: NSDefaultRunLoopMode
|
||||
dequeue: YES])
|
||||
if (isEventBlockedByModalComps == nullptr || ! (*isEventBlockedByModalComps) (e))
|
||||
[NSApp sendEvent: e];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue