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

将 NSTimer 改成 [NSMachPort port] 是否更好 #12

Open
JerseyBro opened this issue Nov 24, 2019 · 0 comments
Open

将 NSTimer 改成 [NSMachPort port] 是否更好 #12

JerseyBro opened this issue Nov 24, 2019 · 0 comments

Comments

@JerseyBro
Copy link

@implementation DWURunLoopWorkDistribution
- (instancetype)init
{
    if ((self = [super init])) {
        _maximumQueueLength = 30;
        _tasks = [NSMutableArray array];
        _tasksKeys = [NSMutableArray array];
//        _timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(_timerFiredMethod:) userInfo:nil repeats:YES];
         // 如果不加延迟会导致启动黑屏,  可能是由于启动 App 时, 无法正常 Mode 切换的原因;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
            [runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];
            [runLoop run];
        });

    }
    return self;
}
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