Merge branch 'feature/additional_dispatch_method' into 'develop'
Add dispatch async on queue. See merge request BPHV_MIPS/mvm_core!30
This commit is contained in:
commit
14a06fde09
@ -19,6 +19,7 @@
|
||||
+ (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.
|
||||
+ (void)performBlock:(nonnull void (^)(void))block onQueue:(dispatch_queue_t)queue;
|
||||
+ (void)performSyncBlock:(nonnull void (^)(void))block onQueue:(nonnull dispatch_queue_t)queue;
|
||||
|
||||
@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 {
|
||||
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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user