iOS GCD(6)
}
//这里指定等待时间1s,即1s后查看dispatch group中的处理是否全部执行结束
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, 1ull*NSEC_PER_SEC);
long result = dispatch_group_wait(group, time);
if (result == 0) {
//属于dispatch group中的全部处理都执行结束
}
else {
//属于dispatch group的某一个处理还在执行
}
[cpp]
//这里也可以指定DISPATCH_TIME_NOW,则不用任何等待即可判断属于dispatch group中的处理是否全部执行结束
long result = dispatch_group_wait(group, DISPATCH_TIME_NOW);
//这里也可以指定DISPATCH_TIME_NOW,则不用任何等待即可判断属于dispatch group中的处理是否全部执行结束
long result = dispatch_group_wait(group, DISPATCH_TIME_NOW);
6、dispatch_barrier_async
[cpp]
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
//表示执行数据读取任务
NSLog(@"blk1_reading");
});
dispatch_async(queue, ^{
NSLog(@"blk2_reading");
});
dispatch_async(queue, ^{
//表示执行数据写入处理任务
NSLog(@"blk1_writting");
});
dispatch_async(queue, ^{
NSLog(@"blk3_reading");
});
dispatch_async(queue, ^{
NSLog(@"blk4_reading");
});
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
//表示执行数据读取任务
NSLog(@"blk1_reading");
});
dispatch_async(queue, ^{
NSLog(@"blk2_reading");
});
dispatch_async(queue, ^{
//表示执行数据写入处理任务
NSLog(@"blk1_writting");
相关新闻>>
- 发表评论
-
- 最新评论 更多>>