mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
[ASDeallocQueue] Fix teardown of thread (doesn't currently happen due to singleton). (#2410)
Although this didn't occur _currently_, the code was incorrect and needs to be fixed.
This commit is contained in:
@@ -79,7 +79,7 @@ static void runLoopSourceCallback(void *info) {
|
|||||||
|
|
||||||
[_condition lock];
|
[_condition lock];
|
||||||
[_condition signal];
|
[_condition signal];
|
||||||
// At this moment, the thread is guaranteed to be finished starting.
|
// At this moment, -init is signalled that the thread is guaranteed to be finished starting.
|
||||||
[_condition unlock];
|
[_condition unlock];
|
||||||
|
|
||||||
// Keep processing events until the runloop is stopped.
|
// Keep processing events until the runloop is stopped.
|
||||||
@@ -87,6 +87,12 @@ static void runLoopSourceCallback(void *info) {
|
|||||||
|
|
||||||
CFRunLoopTimerInvalidate(timer);
|
CFRunLoopTimerInvalidate(timer);
|
||||||
CFRunLoopRemoveTimer(runloop, timer, kCFRunLoopCommonModes);
|
CFRunLoopRemoveTimer(runloop, timer, kCFRunLoopCommonModes);
|
||||||
|
CFRelease(timer);
|
||||||
|
|
||||||
|
[_condition lock];
|
||||||
|
[_condition signal];
|
||||||
|
// At this moment, -stop is signalled that the thread is guaranteed to be finished exiting.
|
||||||
|
[_condition unlock];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,6 +122,7 @@ static void runLoopSourceCallback(void *info) {
|
|||||||
[_condition lock];
|
[_condition lock];
|
||||||
[self performSelector:@selector(_stop) onThread:_thread withObject:nil waitUntilDone:NO];
|
[self performSelector:@selector(_stop) onThread:_thread withObject:nil waitUntilDone:NO];
|
||||||
[_condition wait];
|
[_condition wait];
|
||||||
|
// At this moment, the thread is guaranteed to be finished running.
|
||||||
[_condition unlock];
|
[_condition unlock];
|
||||||
_thread = nil;
|
_thread = nil;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user