Add support for run loop queues with no handler, optimize

This commit is contained in:
Adlai Holler
2016-11-20 15:55:18 +09:00
parent 6d01bbeb19
commit 887f48cbda
3 changed files with 30 additions and 15 deletions

View File

@@ -16,8 +16,19 @@ NS_ASSUME_NONNULL_BEGIN
@interface ASRunLoopQueue<ObjectType> : NSObject
/**
* Create a new queue with the given run loop and handler.
*
* @param runloop The run loop that will drive this queue.
* @param handlerBlock An optional block to be run for each enqueued object.
*
* @discussion You may pass @c nil for the handler if you simply want the objects to
* be retained at enqueue time, and released during the run loop step. This is useful
* for creating a "main deallocation queue", as @c ASDeallocQueue creates its own
* worker thread with its own run loop.
*/
- (instancetype)initWithRunLoop:(CFRunLoopRef)runloop
andHandler:(void(^)(ObjectType dequeuedItem, BOOL isQueueDrained))handlerBlock;
andHandler:(nullable void(^)(ObjectType dequeuedItem, BOOL isQueueDrained))handlerBlock;
- (void)enqueue:(ObjectType)object;