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

ping主线程可以简化 #6

Open
ZQZzzzzz opened this issue Mar 23, 2019 · 1 comment
Open

ping主线程可以简化 #6

ZQZzzzzz opened this issue Mar 23, 2019 · 1 comment

Comments

@ZQZzzzzz
Copy link

感谢分享这么好的文章,确实可以检测定位到主线程耗时函数,但是ping方法好像可以简化,NSNotificationCenter通知是多余的,ping对应dispatch而不是postNotificationName,pingMainThread函数可以改写成这样:
`- (void)pingMainThread
{
uint64_t interval = PMainThreadWatcher_Warning_Level * NSEC_PER_SEC;
self.pongTimer = createGCDTimer(interval, interval / 10000, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self onPongTimeout];
});

dispatch_async(dispatch_get_main_queue(), ^{
    [self cancelPongTimer];
});

}`

@xinweizhou619
Copy link

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