mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
New runloop queue to coalesce Interface state update calls. (#788)
* fix SIMULATE_WEB_RESPONSE not imported #449 * Coalesce interface state updates to ASCATransactionQueue before CATransaction commit. This will avoid duplicate interface state delegate calls caused by view repeatly added/removed to/from hierarchy during controller animation transition. * fix tests for new run loop queue * Support for disabling ASCATransactionQueue * Fix didExitHierarchy to use ASCATransactionQueue. * merge range managed and none range managed for didExitHierarchy * Revert "merge range managed and none range managed for didExitHierarchy" This reverts commit f807efaa65ed5dbdb6622d06da542e01a53715fa. * merge range managed and none range managed for didExitHierarchy * remove metadata * abstract queue to impl class methods * Add tests * Fix test fail because of shared object. * guard _pendingInterfaceState access with lock * name refactor * Refactor from comments https://github.com/TextureGroup/Texture/pull/788/\#pullrequestreview-94849919 * Apply InterfaceState immediately after ASCATranactionQueue is processed and before next runloop started. * refactor * no op to start CI build * remove unused var and kick off tests * change lisence * remove code for weak ref * add change log and adjust license
This commit is contained in:
@@ -20,8 +20,15 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol ASCATransactionQueueObserving <NSObject>
|
||||
- (void)prepareForCATransactionCommit;
|
||||
@end
|
||||
|
||||
@interface ASAbstractRunLoopQueue : NSObject
|
||||
@end
|
||||
|
||||
AS_SUBCLASSING_RESTRICTED
|
||||
@interface ASRunLoopQueue<ObjectType> : NSObject <NSLocking>
|
||||
@interface ASRunLoopQueue<ObjectType> : ASAbstractRunLoopQueue <NSLocking>
|
||||
|
||||
/**
|
||||
* Create a new queue with the given run loop and handler.
|
||||
@@ -41,13 +48,37 @@ AS_SUBCLASSING_RESTRICTED
|
||||
|
||||
- (void)enqueue:(ObjectType)object;
|
||||
|
||||
@property (nonatomic, readonly) BOOL isEmpty;
|
||||
@property (atomic, readonly) BOOL isEmpty;
|
||||
|
||||
@property (nonatomic, assign) NSUInteger batchSize; // Default == 1.
|
||||
@property (nonatomic, assign) BOOL ensureExclusiveMembership; // Default == YES. Set-like behavior.
|
||||
|
||||
@end
|
||||
|
||||
AS_SUBCLASSING_RESTRICTED
|
||||
@interface ASCATransactionQueue : ASAbstractRunLoopQueue
|
||||
|
||||
@property (atomic, readonly) BOOL isEmpty;
|
||||
@property (atomic, readonly) BOOL disabled;
|
||||
/**
|
||||
* The queue to run on main run loop before CATransaction commit.
|
||||
*
|
||||
* @discussion this queue will run after ASRunLoopQueue and before CATransaction commit
|
||||
* to get last chance of updating/coalesce info like interface state.
|
||||
* Each node will only be called once per transaction commit to reflect interface change.
|
||||
*/
|
||||
@property (class, atomic, readonly) ASCATransactionQueue *sharedQueue;
|
||||
|
||||
- (void)enqueue:(id<ASCATransactionQueueObserving>)object;
|
||||
|
||||
/**
|
||||
* @abstract Apply a node's interfaceState immediately rather than adding to the queue.
|
||||
*/
|
||||
- (void)disable;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
AS_SUBCLASSING_RESTRICTED
|
||||
@interface ASDeallocQueue : NSObject
|
||||
|
||||
|
||||
Reference in New Issue
Block a user