dispatch_semaphore_t semaphore = dispatch_semaphore_create(5);
- (void)request:(void(^)(NSDictionary *))callback {
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
dispatch_semaphore_signal(semaphore);
callback(@{});
});
}
网友评论