dispatch_queue_t t = dispatch_queue_create("com.hello", DISPATCH_QUEUE_CONCURRENT);
dispatch_queue_t gt = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
//设置quene优先级
dispatch_set_target_queue(t, gt);
//dispatch_time定义相对时间
dispatch_time_t time_t = dispatch_time(DISPATCH_TIME_NOW, 3ull * NSEC_PER_SEC);
dispatch_after(time_t, dispatch_get_main_queue(), ^{
});
//通过timespec 定义绝对时间
NSTimeInterval interval = [[NSDate date] timeIntervalSince1970];
doublesec, subsec;
subsec =modf(interval, &sec);
structtimespectime;
time.tv_sec= sec;
time.tv_nsec= subsec *NSEC_PER_SEC;
dispatch_time_t wtime_t = dispatch_walltime(&time, 0);
dispatch_group_t group_t = dispatch_group_create();
dispatch_group_async(group_t, gt, ^{
});
dispatch_group_notify(group_t, gt, ^{
});
//DISPATCH_QUEUE_CONCURRENT quene 在已经提交到quene中的任务完成后加入,
// on such a queue, a barrier block
// * will not run until all blocks submitted to the queue earlier have completed,
// * and any blocks submitted to the queue after a barrier block will not run
// * until the barrier block has completed.
dispatch_barrier_async(gt, ^{
});
//等待全部执行完成 done才执行
dispatch_apply(10, gt, ^(size_titeration) {
});
NSLog(@"done");
//挂起和恢复quene
dispatch_suspend(t);
dispatch_resume(t);
dispatch_semaphore_t sema_t = dispatch_semaphore_create(1);
dispatch_semaphore_signal(sema_t);
dispatch_semaphore_wait(sema_t, DISPATCH_TIME_FOREVER);
// dispatch_source_t?