QueueScheduler
public final class QueueScheduler : DateScheduler
A scheduler backed by a serial GCD queue.
-
A singleton
QueueSchedulerthat always targets the main thread’s GCD queue.Note
UnlikeUIScheduler, this scheduler supports scheduling for a future date, and will always schedule asynchronously (even if already running on the main thread).Declaration
Swift
public static let main: QueueScheduler -
Declaration
Swift
public var currentDate: Date { get } -
Initializes a scheduler that will target the given queue with its work.
Note
Even if the queue is concurrent, all work items enqueued with the
QueueSchedulerwill be serial with respect to each other.Warning
Obsoleted in OS X 10.11
Declaration
Swift
@available(OSX, deprecated: 10.10, obsoleted: 10.11, message: "Use init(qos:name:targeting:) instead") @available(iOS, deprecated: 8.0, obsoleted: 9.0, message: "Use init(qos:name:targeting:) instead.") public convenience init(queue: DispatchQueue, name: String = "org.reactivecocoa.ReactiveSwift.QueueScheduler") -
Initializes a scheduler that creates a new serial queue with the given quality of service class.
Declaration
Swift
@available(OSX 10.10, *) public convenience init( qos: DispatchQoS = .default, name: String = "org.reactivecocoa.ReactiveSwift.QueueScheduler", targeting targetQueue: DispatchQueue? = nil )Parameters
qosDispatch queue’s QoS value.
nameA name for the queue in the form of reverse domain.
targeting(Optional) The queue on which this scheduler’s work is targeted
-
Schedules action for dispatch on internal queue
Declaration
Swift
@discardableResult public func schedule(_ action: @escaping () -> Void) -> Disposable ?Parameters
actionA closure of the action to be scheduled.
Return Value
Disposablethat can be used to cancel the work before it begins. -
Schedules an action for execution at or after the given date.
Declaration
Swift
@discardableResult public func schedule(after date: Date, action: @escaping () -> Void) -> Disposable ?Parameters
dateThe start date.
actionA closure of the action to be performed.
Return Value
Optional
Disposablethat can be used to cancel the work before it begins. -
Schedules a recurring action at the given interval and beginning at the given start date. A reasonable default timer interval leeway is provided.
Note
If you plan to specify an
intervalvalue greater than 200,000 seconds, useschedule(after:interval:leeway:action)instead and specify your ownleewayvalue to avoid potential overflow.Declaration
Swift
@discardableResult public func schedule(after date: Date, interval: DispatchTimeInterval, action: @escaping () -> Void) -> Disposable ?Parameters
dateA date to schedule the first action for.
intervalA repetition interval.
actionClosure of the action to repeat.
Return Value
Optional disposable that can be used to cancel the work before it begins.
-
Schedules a recurring action at the given interval with provided leeway, beginning at the given start time.
Precondition
intervalmust be non-negative number.Precondition
leewaymust be non-negative number.Declaration
Swift
@discardableResult public func schedule(after date: Date, interval: DispatchTimeInterval, leeway: DispatchTimeInterval, action: @escaping () -> Void) -> Disposable ?Parameters
dateA date to schedule the first action for.
intervalA repetition interval.
leewaySome delta for repetition interval.
actionA closure of the action to repeat.
Return Value
Optional
Disposablethat can be used to cancel the work before it begins.