mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-20 13:19:16 +00:00
Make a public function ASPerformMainThreadDeallocation
This commit is contained in:
parent
71872a298e
commit
9a762f9832
@ -457,17 +457,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
- (void)_scheduleIvarsForMainDeallocation
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
});
|
||||
|
||||
NSValue *ivarsObj = [[self class] _ivarsThatMayNeedMainDeallocation];
|
||||
|
||||
// Unwrap the ivar array
|
||||
@ -482,7 +471,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
id value = object_getIvar(self, ivar);
|
||||
if (ASClassRequiresMainThreadDeallocation(object_getClass(value))) {
|
||||
LOG(@"Trampolining ivar '%s' value %@ for main deallocation.", ivar_getName(ivar), value);
|
||||
[queue enqueue:value];
|
||||
ASPerformMainThreadDeallocation(value);
|
||||
} else {
|
||||
LOG(@"Not trampolining ivar '%s' value %@.", ivar_getName(ivar), value);
|
||||
}
|
||||
|
||||
@ -14,6 +14,9 @@
|
||||
#import <AsyncDisplayKit/ASBaseDefines.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode.h>
|
||||
|
||||
/// For deallocation of objects on the main thread across multiple run loops.
|
||||
extern void ASPerformMainThreadDeallocation(_Nullable id object);
|
||||
|
||||
// Because inline methods can't be extern'd and need to be part of the translation unit of code
|
||||
// that compiles with them to actually inline, we both declare and define these in the header.
|
||||
ASDISPLAYNODE_INLINE BOOL ASInterfaceStateIncludesVisible(ASInterfaceState interfaceState)
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user