mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Make a public function ASPerformMainThreadDeallocation
This commit is contained in:
@@ -13,6 +13,24 @@
|
||||
#import "ASDisplayNode+FrameworkPrivate.h"
|
||||
|
||||
#import <queue>
|
||||
#import "ASRunLoopQueue.h"
|
||||
|
||||
extern void ASPerformMainThreadDeallocation(_Nullable id object)
|
||||
{
|
||||
/**
|
||||
* UIKit components must be deallocated on the main thread. We use this shared
|
||||
* run loop queue to gradually deallocate them across many turns of the main run loop.
|
||||
*/
|
||||
static ASRunLoopQueue *queue;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
queue = [[ASRunLoopQueue alloc] initWithRunLoop:CFRunLoopGetMain() andHandler:nil];
|
||||
queue.batchSize = 10;
|
||||
});
|
||||
if (object != nil) {
|
||||
[queue enqueue:object];
|
||||
}
|
||||
}
|
||||
|
||||
extern ASInterfaceState ASInterfaceStateForDisplayNode(ASDisplayNode *displayNode, UIWindow *window)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user