I\'m just playing around with GCD and I\'ve written a toy CoinFlipper app.
Here\'s the method that flips the coins:
- (void)flipCoins:(NSUInteger)nFl
If you have a serial dispatch queue OR a concurrent dispatch queue, here is a code that can do the same thing.
BOOL __block queueIsEmpty = false;
dispatch_barrier_async (_dispatchQueue, ^{
queueIsEmpty = true;
});
while (!queueIsEmpty) {
int i = 0; // NOOP instruction
}
// At this point your queue should be empty.