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:
Max Wang
2018-02-13 12:10:20 -08:00
committed by Adlai Holler
parent 6f34691481
commit 2618c50073
13 changed files with 445 additions and 66 deletions

View File

@@ -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