-
Notifications
You must be signed in to change notification settings - Fork 492
Open
Description
why pinging run with mainthread? in children thread will call bug?
The code :
-
(void)pingWithBlock:(void (^)(BOOL isSuccess, NSTimeInterval latency))completion
{
//NSLog(@"pingWithBlock");
if (completion)
{
// copy the block, then added to the blocks array.
@synchronized(self)
{
[self.completionBlocks addObject:[completion copy]];
}
}if (!self.isPinging)
{
// MUST make sure pingFoundation in mainThread
__weak __typeof(self)weakSelf = self;
if (![[NSThread currentThread] isMainThread]) {
dispatch_sync(dispatch_get_main_queue(), ^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf startPing];
});
}
else
{
[self startPing];
}
}
}
Metadata
Metadata
Assignees
Labels
No labels