Why the code if (dispatch_get_current_queue() == socketQueue)
is needed? why can't we just use dispatch_sync(socketQueue, block)
directly???
Thanks in advance!
- (BOOL)isConnected
{
__block BOOL result = NO;
dispatch_block_t block = ^{
result = (flags & kConnected) ? YES : NO;
};
if (dispatch_get_current_queue() == socketQueue)
block();
else
dispatch_sync(socketQueue, block);
return result;
}
BTW, the code is from XMPPFramework