美文网首页
多个接口请求顺序copy

多个接口请求顺序copy

作者: 白貂 | 来源:发表于2017-10-19 11:07 被阅读0次

//数据请求

-(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);

});

}

转载:http://blog.sina.com.cn/s/blog_147d0371c0102wi1p.html

相关文章

网友评论

      本文标题:多个接口请求顺序copy

      本文链接:https://www.haomeiwen.com/subject/rykuuxtx.html