Add dispatch async on queue.
This commit is contained in:
parent
e59e77d163
commit
d7fa319b05
@ -19,6 +19,7 @@
|
|||||||
+ (void)performSyncBlockInBackground:(nonnull void (^)(void))block;
|
+ (void)performSyncBlockInBackground:(nonnull void (^)(void))block;
|
||||||
|
|
||||||
/// Ensures the block is peformed on the same *labeled* dispatch queue. The queue *must* be previously initialized with a unique label.
|
/// Ensures the block is peformed on the same *labeled* dispatch queue. The queue *must* be previously initialized with a unique label.
|
||||||
|
+ (void)performBlock:(nonnull void (^)(void))block onQueue:(dispatch_queue_t)queue;
|
||||||
+ (void)performSyncBlock:(nonnull void (^)(void))block onQueue:(nonnull dispatch_queue_t)queue;
|
+ (void)performSyncBlock:(nonnull void (^)(void))block onQueue:(nonnull dispatch_queue_t)queue;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -42,6 +42,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (void)performBlock:(nonnull void (^)(void))block onQueue:(dispatch_queue_t)queue {
|
||||||
|
assert(dispatch_queue_get_label(queue) != NULL); // The queue being queried MUST have a label.
|
||||||
|
const char *currQueueLabel = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
|
||||||
|
if (!currQueueLabel || strcmp(dispatch_queue_get_label(queue), currQueueLabel) != 0) {
|
||||||
|
dispatch_async(queue, block);
|
||||||
|
} else {
|
||||||
|
block();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)performSyncBlock:(nonnull void (^)(void))block onQueue:(dispatch_queue_t)queue {
|
+ (void)performSyncBlock:(nonnull void (^)(void))block onQueue:(dispatch_queue_t)queue {
|
||||||
assert(dispatch_queue_get_label(queue) != NULL); // The queue being queried MUST have a label.
|
assert(dispatch_queue_get_label(queue) != NULL); // The queue being queried MUST have a label.
|
||||||
const char *currQueueLabel = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
|
const char *currQueueLabel = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user