Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NS_INLINE void OnMainThread(int64_t after_sec, dispatch_block_t block)
- {
- if (!block)
- return;
- else if (after_sec > 0)
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(after_sec * NSEC_PER_SEC)), dispatch_get_main_queue(), block);
- else if ([NSThread isMainThread])
- block();
- else
- dispatch_async(dispatch_get_main_queue(), block);
- }
- NS_INLINE void OnNewThread(long priority, int64_t after_sec, dispatch_block_t block)
- {
- if (!block)
- return;
- else if (after_sec > 0)
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(after_sec * NSEC_PER_SEC)), dispatch_get_global_queue(priority, 0), block);
- else if (![NSThread isMainThread])
- block();
- else
- dispatch_async(dispatch_get_global_queue(priority, 0), block);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement