FWTaskManager

@interface FWTaskManager : NSObject

任务管理器,兼容NSBlockOperation和NSInvocationOperation

  • 单例模式

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) FWTaskManager *_Nonnull sharedInstance;
  • 并发操作的最大任务数

    Declaration

    Objective-C

    @property (nonatomic) NSInteger maxConcurrentTaskCount;
  • 是否暂停,可恢复

    Declaration

    Objective-C

    @property (nonatomic) BOOL isSuspended;
  • 添加单个任务

    Declaration

    Objective-C

    - (void)addTask:(nonnull NSOperation *)task;
  • 批量添加任务

    Declaration

    Objective-C

    - (void)addTasks:(nonnull NSArray<NSOperation *> *)tasks;
  • 从配置数组按顺序添加任务,支持className|dependency

    Declaration

    Objective-C

    - (void)addTaskConfig:(nonnull NSArray<NSDictionary *> *)config;
  • 取消所有任务

    Declaration

    Objective-C

    - (void)cancelAllTasks;
  • 等待所有任务执行完成,会阻塞线程

    Declaration

    Objective-C

    - (void)waitUntilFinished;