TaskManager
open class TaskManager : @unchecked Sendable
任务管理器,兼容NSBlockOperation和NSInvocationOperation
-
单例模式
Declaration
Swift
public static let shared: TaskManager
-
并发操作的最大任务数
Declaration
Swift
open var maxConcurrentTaskCount: Int { get set }
-
是否暂停,可恢复
Declaration
Swift
open var isSuspended: Bool { get set }
-
Undocumented
Declaration
Swift
public init()
-
Undocumented
Declaration
Swift
public convenience init(maxConcurrentTaskCount: Int, isSuspended: Bool = false)
-
添加单个任务
Declaration
Swift
open func addTask(_ task: Operation)
-
批量添加任务
Declaration
Swift
open func addTasks(_ tasks: [Operation])
-
从配置数组按顺序添加任务,支持className|dependency
Declaration
Swift
open func addTaskConfig(_ config: [[String : String]])
-
取消所有任务
Declaration
Swift
open func cancelAllTasks()
-
等待所有任务执行完成,会阻塞线程
Declaration
Swift
open func waitUntilFinished()