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_apply进行快速迭代 #14

Open
zColdWater opened this issue May 28, 2020 · 0 comments

Comments

@zColdWater
Copy link

for (size_t y = 0; y < height; ++y) {
for (size_t x = 0; x < width; ++x) {
// Do something with x and y here
}
}
//因为可以并行执行,所以使用dispatch_apply可以运行的更快

  • (void)dispatchApplyDemo {
    dispatch_queue_t concurrentQueue = dispatch_queue_create("com.starming.gcddemo.concurrentqueue", DISPATCH_QUEUE_CONCURRENT);
    dispatch_apply(10, concurrentQueue, ^(size_t i) {
    NSLog(@"%zu",i);
    });
    NSLog(@"The end"); //这里有个需要注意的是,dispatch_apply这个是会阻塞主线程的。这个log打印会在dispatch_apply都结束后才开始执行
    }

纠正的地方:“dispatch_apply这个是会阻塞主线程的” 改成 “dispatch_apply这个是会阻塞当前上下文线程的”

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

1 participant