Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于XMChainRequest,我的一些想法 #42

Open
Xwnine opened this issue May 11, 2018 · 2 comments
Open

关于XMChainRequest,我的一些想法 #42

Xwnine opened this issue May 11, 2018 · 2 comments

Comments

@Xwnine
Copy link

Xwnine commented May 11, 2018

与BatchRequest不同,我的理解是,链式调用其实就是同步多个XMRequest的发起和返回,在我们的项目中,我是使用dispatch_group 来做同步的,最终实现的ChainRequest调用方式和您这个BatchRequest 一样的,也是传入一组requestArray,利用requestArray 实现一个Queue的数据结构,所以能够保证request的发起顺序,并同步responseObject在responseArray的位置。而在您的项目中XMChainRequest的实现方式其实和我的方式差不多吧,不过您是使用dispatch_semaphore_t 配合游标_chainIndex来做同步。哈哈哈,突然有个想法,dispatch_group工作原理就是这么干的?

�回到正题,两种方式哪个新能更好?健壮性更高?出于本能吧,看到 [_responseArray addObject:[NSNull null]]; 以及[_responseArray replaceObjectAtIndex:index withObject:responseObject]; 心里就会停顿,总是会担心Crash。

@a455455b
Copy link

dispatch_group 就是用的信号量 差不太多啦

@Xwnine
Copy link
Author

Xwnine commented Aug 13, 2018

翻了下gcd源码,dispatch_group本身也是用的信号量来实现

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants