mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +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 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];
|
||||
|
||||
// Keep processing events until the runloop is stopped.
|
||||
@@ -87,6 +87,12 @@ static void runLoopSourceCallback(void *info) {
|
||||
|
||||
CFRunLoopTimerInvalidate(timer);
|
||||
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];
|
||||
[self performSelector:@selector(_stop) onThread:_thread withObject:nil waitUntilDone:NO];
|
||||
[_condition wait];
|
||||
// At this moment, the thread is guaranteed to be finished running.
|
||||
[_condition unlock];
|
||||
_thread = nil;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user