QNAsyncRun.m 651 B

12345678910111213141516171819202122232425262728
  1. //
  2. // QNAsyncRun.m
  3. // QiniuSDK
  4. //
  5. // Created by bailong on 14/10/17.
  6. // Copyright (c) 2014年 Qiniu. All rights reserved.
  7. //
  8. #import "QNAsyncRun.h"
  9. #import <Foundation/Foundation.h>
  10. void QNAsyncRun(QNRun run) {
  11. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
  12. run();
  13. });
  14. }
  15. void QNAsyncRunInMain(QNRun run) {
  16. dispatch_async(dispatch_get_main_queue(), ^(void) {
  17. run();
  18. });
  19. }
  20. void QNAsyncRunAfter(NSTimeInterval time, dispatch_queue_t queue, QNRun run) {
  21. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), queue, ^{
  22. run();
  23. });
  24. }