Use the dispatch semaphore to reduce the impact of PerformBlockOnThread by waiting on it with a short timeout. This loop can't wait forever because the run-loop source may need to be rescheduled to complete the outstanding work.

[CL 2654646 by Mark Satterthwaite in Main branch]
This commit is contained in:
Mark Satterthwaite
2015-08-13 10:55:02 -04:00
committed by Mark.Satterthwaite@epicgames.com
parent e72ff42108
commit f7d222868b

View File

@@ -393,13 +393,11 @@ static void PerformBlockOnThread(FCocoaRunLoopSource& ThreadSource, dispatch_blo
dispatch_block_t ExecuteBlock = Block_copy(^{ CopiedBlock(); dispatch_semaphore_signal(Semaphore); });
ThreadSource.Schedule(ExecuteBlock, SendModes);
ThreadSource.Wake();
while (dispatch_semaphore_wait(Semaphore, DISPATCH_TIME_NOW))
{
ThreadSource.RunInMode( (CFStringRef)WaitMode );
do {
ThreadSource.Wake();
}
ThreadSource.RunInMode( (CFStringRef)WaitMode );
} while (dispatch_semaphore_wait(Semaphore, dispatch_time(0, 100000ull)));
Block_release(ExecuteBlock);
dispatch_release(Semaphore);