QueueScheduler

public final class QueueScheduler : DateScheduler

A scheduler backed by a serial GCD queue.

  • A singleton QueueScheduler that always targets the main thread’s GCD queue.

    Note

    Unlike UIScheduler, 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 QueueScheduler will 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

    qos

    Dispatch queue’s QoS value.

    name

    A 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

    action

    A closure of the action to be scheduled.

    Return Value

    Disposable that 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

    date

    The start date.

    action

    A closure of the action to be performed.

    Return Value

    Optional Disposable that 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 interval value greater than 200,000 seconds, use schedule(after:interval:leeway:action) instead and specify your own leeway value to avoid potential overflow.

    Declaration

    Swift

    @discardableResult
    public func schedule(after date: Date, interval: DispatchTimeInterval, action: @escaping () -> Void) -> Disposable?

    Parameters

    date

    A date to schedule the first action for.

    interval

    A repetition interval.

    action

    Closure 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

    interval must be non-negative number.

    Precondition

    leeway must be non-negative number.

    Declaration

    Swift

    @discardableResult
    public func schedule(after date: Date, interval: DispatchTimeInterval, leeway: DispatchTimeInterval, action: @escaping () -> Void) -> Disposable?

    Parameters

    date

    A date to schedule the first action for.

    interval

    A repetition interval.

    leeway

    Some delta for repetition interval.

    action

    A closure of the action to repeat.

    Return Value

    Optional Disposable that can be used to cancel the work before it begins.