grand-central-dispatch
How can I wait for an async function from synchronous function in Swift 5.5?
You could maybe argue that asynchronous code doesn’t belong in setUp(), but it seems to me that to do so would be to conflate synchronicity with sequential…icity? The point of setUp() is to run before anything else begins running, but that doesn’t mean it has to be written synchronously, only that everything else needs to … Read more
Pattern for unit testing async queue that calls main queue on completion
There are two ways to get blocks dispatched to the main queue to run. The first is via dispatch_main, as mentioned by Drewsmits. However, as he also noted, there’s a big problem with using dispatch_main in your test: it never returns. It will just sit there waiting to run any blocks that come its way … Read more
FIFO serial queue using GCD
This is a FIFO queue in GCD: dispatch_queue_t serialQueue = dispatch_queue_create(“com.blah.queue”, DISPATCH_QUEUE_SERIAL); … dispatch_async(serialQueue, ^{ //block1 }); dispatch_async(serialQueue, ^{ //block2 });