123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //
- // YYDispatchQueueManager.h
- // YYKit <https://github.com/ibireme/YYKit>
- //
- // Created by ibireme on 15/7/18.
- // Copyright (c) 2015 ibireme.
- //
- // This source code is licensed under the MIT-style license found in the
- // LICENSE file in the root directory of this source tree.
- //
- #import <Foundation/Foundation.h>
- #ifndef YYDispatchQueuePool_h
- #define YYDispatchQueuePool_h
- NS_ASSUME_NONNULL_BEGIN
- /**
- A dispatch queue pool holds multiple serial queues.
- Use this class to control queue's thread count (instead of concurrent queue).
- */
- @interface YYDispatchQueuePool : NSObject
- - (instancetype)init UNAVAILABLE_ATTRIBUTE;
- + (instancetype)new UNAVAILABLE_ATTRIBUTE;
- /**
- Creates and returns a dispatch queue pool.
- @param name The name of the pool.
- @param queueCount Maxmium queue count, should in range (1, 32).
- @param qos Queue quality of service (QOS).
- @return A new pool, or nil if an error occurs.
- */
- - (instancetype)initWithName:(nullable NSString *)name queueCount:(NSUInteger)queueCount qos:(NSQualityOfService)qos;
- /// Pool's name.
- @property (nullable, nonatomic, readonly) NSString *name;
- /// Get a serial queue from pool.
- - (dispatch_queue_t)queue;
- + (instancetype)defaultPoolForQOS:(NSQualityOfService)qos;
- @end
- /// Get a serial queue from global queue pool with a specified qos.
- extern dispatch_queue_t YYDispatchQueueGetForQOS(NSQualityOfService qos);
- NS_ASSUME_NONNULL_END
- #endif
|