//数据请求
-(void)initData
{
[[LoadingClassshared]showLoading:@"正在加载..."];
//创建信号量
dispatch_semaphore_tsemaphore =dispatch_semaphore_create(0);
//创建全局并行
dispatch_queue_tqueue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
dispatch_group_tgroup =dispatch_group_create();
dispatch_group_async(group, queue, ^{
//请求一
[selftenderBaseRequest];
dispatch_semaphore_signal(semaphore);
});
dispatch_group_async(group, queue, ^{
//请求二
[selftenderBidRequest];
dispatch_semaphore_signal(semaphore);
});
dispatch_group_async(group, queue, ^{
//请求三
[selftenderInvalidRequest];
dispatch_semaphore_signal(semaphore);
});
dispatch_group_notify(group, queue, ^{
//三个请求对应三次信号等待
dispatch_semaphore_wait(semaphore,DISPATCH_TIME_FOREVER);
dispatch_semaphore_wait(semaphore,DISPATCH_TIME_FOREVER);
dispatch_semaphore_wait(semaphore,DISPATCH_TIME_FOREVER);
});
}
网友评论