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

有疑问,Dispatch Source “帮” Dispatch Queue 实现暂停和恢复功能 #9

Open
liuzhiyi1992 opened this issue Jul 10, 2016 · 3 comments

Comments

@liuzhiyi1992
Copy link

dispatch queue本来就可以挂起和恢复,为什么说要借助dispatch source呢?

@ChenYilong
Copy link
Owner

帮忙详细描述下“dispatch queue本来就可以挂起和恢复”,最好能贴一下代码,我看下咱们两个讲的东西是不是有出入。

@liuzhiyi1992
Copy link
Author

暂停恢复:使用dispatch_suspend() 和 dispatch_resume() 将队列挂起

取消:通过植入标识对单个任务进行“取消”
__block BOOL cancelled = NO;
void (^task)(BOOL) = ^() {
if (cancelled) {
return;
}
//dosomething
};
也就是文中的通过property(running)来植入“取消”

@liuzhiyi1992
Copy link
Author

@ChenYilong 有空的话帮忙看下,哈哈

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