We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
static void addRunLoopObserver() { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ taskSchedulers = [NSHashTable weakObjectsHashTable]; CFRunLoopObserverRef observer = CFRunLoopObserverCreate(CFAllocatorGetDefault(), kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, 0xFFFFFF, runLoopObserverCallBack, NULL); CFRunLoopAddObserver(CFRunLoopGetMain(), observer, kCFRunLoopCommonModes); CFRelease(observer); }); }
利用runloop,将我们收敛的任务执行在runloop运行期间。但是注意到,永远是在main runloop 触发这些任务的执行的。假如,我在子线程中添加了任务,但是主线程卡住了。意味着主线程的runloop 不能够及时的触发状态回调而触发任务执行。而受到牵连的在子线程添加的任务不能够及时执行。这种情况子线程的任务执行情况反而依赖于主线程的卡顿情况. 主线程的卡顿,反而影响到了子线程的执行效率 如果主线程极端卡顿的情况下。多线程执行的优势就不存在了~
The text was updated successfully, but these errors were encountered:
你说的情况是存在的,不过一个正常的 APP 主线程一般不会长时间卡顿。 这算是一个可优化的地方,可以让用户指定任务调度的线程。
Sorry, something went wrong.
No branches or pull requests
static void addRunLoopObserver() { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ taskSchedulers = [NSHashTable weakObjectsHashTable]; CFRunLoopObserverRef observer = CFRunLoopObserverCreate(CFAllocatorGetDefault(), kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, 0xFFFFFF, runLoopObserverCallBack, NULL); CFRunLoopAddObserver(CFRunLoopGetMain(), observer, kCFRunLoopCommonModes); CFRelease(observer); }); }
利用runloop,将我们收敛的任务执行在runloop运行期间。但是注意到,永远是在main runloop 触发这些任务的执行的。假如,我在子线程中添加了任务,但是主线程卡住了。意味着主线程的runloop 不能够及时的触发状态回调而触发任务执行。而受到牵连的在子线程添加的任务不能够及时执行。这种情况子线程的任务执行情况反而依赖于主线程的卡顿情况.
主线程的卡顿,反而影响到了子线程的执行效率
如果主线程极端卡顿的情况下。多线程执行的优势就不存在了~
The text was updated successfully, but these errors were encountered: