Use current run loop instead of main dispatch queue

This change is for the tests which are not being run in the main queue, so it is wrong to assume that we can use the main queue for callbacks.
This commit is contained in:
Allan Odgaard
2016-07-09 15:44:54 +02:00
parent 3d4d8d4ca3
commit 61aa554dbd
2 changed files with 24 additions and 10 deletions

View File

@@ -51,9 +51,10 @@ namespace ng
size_t bufferRev = revision();
auto bufferRef = parser_reference();
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
result_t result = handle_request(grammarRef, state, line, { from, to }, batch_start, limit_redraw);
dispatch_async(dispatch_get_main_queue(), ^{
CFRunLoopPerformBlock(runLoop, kCFRunLoopCommonModes, ^{
if(bufferRef.lock())
{
if(bufferRev == revision())
@@ -61,6 +62,7 @@ namespace ng
else initiate_repair();
}
});
CFRunLoopWakeUp(runLoop);
});
}
else