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

Docs Typo 协程IO阻塞 #80

Open
qs991011 opened this issue May 17, 2019 · 2 comments
Open

Docs Typo 协程IO阻塞 #80

qs991011 opened this issue May 17, 2019 · 2 comments

Comments

@qs991011
Copy link

我想知道,当协程出现IO阻塞时,调度器是如何处理协程调用的,源码中哪里能看到这些细节。谢谢

@pengyutang125
Copy link
Contributor

建议你举个具体的例子,这样我从例子来给你说明

@qs991011
Copy link
Author

建议你举个具体的例子,这样我从例子来给你说明

co_launch(^{
NSLog(@"第一个协程开始执行");
NSString *test = @"很长的一段数据,仅仅是测试";
[test co_writeToFile:[basePath stringByAppendingPathComponent:@"note"] atomically:true encoding:NSUTF8StringEncoding error:nil];
NSLog(@"第一个协程执行完成");

});
co_launch(^{
    NSLog(@"第二个协程开始执行");
});
co_launch(^{
    NSLog(@"第三个协程开始执行");
});

协程一“让出CPU”给协程二的疑惑,没通过调度器,而是利用异步线程,这样理解对吗?

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