QueueExecutor
public final class QueueExecutor : ExecutorProtocol, Cancellable
A thread-safe unbounded executor backed by a serial Dispatch queue.
Submitting futures into this executor from any thread is a safe operation.
Dropping the last reference to the executor, causes it to be deallocated. Any pending tasks tracked by the executor at the time are destroyed as well.
-
Declaration
Swift
public convenience init(label: String, qos: DispatchQoS = .default)
-
Declaration
Swift
public convenience init(targetQueue: DispatchQueue)
-
Declaration
Swift
public var label: String { get }
-
Declaration
Swift
public var capacity: Int { get }
-
Schedules the given future to be executed by this executor.
This method can be called from any thread.
Declaration
Swift
public func trySubmit<F>(_ future: F) -> Result<Void, Never> where F : FutureProtocol, F.Output == Void
-
Suspends execution of futures.
While suspended, the executor buffers submitted futures but does not schedules them for execution until it is resumed again.
This method can be called multiple times. Like a counting semaphore, each call internally increments a counter which is decremented by calls to
resume()
. When this counter drops back to zero, the executor resumes operation.This method can be called from any thread.
Declaration
Swift
public func suspend()
-
Resumes execution of futures.
Calling this method on an executor that is not suspended traps at runtime.
This method can be called from any thread.
Declaration
Swift
public func resume()
-
Cancels further execution of futures.
This method can be called from any thread.
Declaration
Swift
public func cancel()
-
Blocks the current thread until all futures tracked by this executor complete.
This method can be called from any thread.
Declaration
Swift
public func wait()
-
An executor backed by the main Dispatch queue.
Declaration
Swift
public static let main: QueueExecutor
-
An executor backed by the default QoS global Dispatch queue.
Declaration
Swift
public static let global: QueueExecutor
-
An executor backed by the
user interactive
QoS global Dispatch queue.Declaration
Swift
public static let userInteractive: QueueExecutor
-
An executor backed by the
user initiated
QoS global Dispatch queue.Declaration
Swift
public static let userInitiated: QueueExecutor
-
An executor backed by the
utility
QoS global Dispatch queue.Declaration
Swift
public static let utility: QueueExecutor
-
An executor backed by the
background
QoS global Dispatch queue.Declaration
Swift
public static let background: QueueExecutor