Back to Rxswift

SerialDispatchQueueScheduler

docs/Classes/SerialDispatchQueueScheduler.html

6.10.26.3 KB
Original Source

SerialDispatchQueueScheduler

public class SerialDispatchQueueScheduler : SchedulerType

Abstracts the work that needs to be performed on a specific dispatch_queue_t. It will make sure that even if concurrent dispatch queue is passed, it’s transformed into a serial one.

It is extremely important that this scheduler is serial, because certain operator perform optimizations that rely on that property.

Because there is no way of detecting is passed dispatch queue serial or concurrent, for every queue that is being passed, worst case (concurrent) will be assumed, and internal serial proxy dispatch queue will be created.

This scheduler can also be used with internal serial queue alone.

In case some customization need to be made on it before usage, internal serial queue can be customized using serialQueueConfiguration callback.

`

                TimeInterval
                `

Undocumented

Declaration

Swift

public typealias TimeInterval = Foundation.TimeInterval

`

                Time
                `

Undocumented

Declaration

Swift

public typealias Time = Date

`

                now
                `

Declaration

Swift

public var now: Date { get }

Return Value

Current time.

`

                init(internalSerialQueueName:serialQueueConfiguration:leeway:)
                `

Constructs new SerialDispatchQueueScheduler with internal serial queue named internalSerialQueueName.

Additional dispatch queue properties can be set after dispatch queue is created using serialQueueConfiguration.

Declaration

Swift

public convenience init(internalSerialQueueName: String, serialQueueConfiguration: ((DispatchQueue) -> Void)? = nil, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0))

Parameters

| internalSerialQueueName |

Name of internal serial dispatch queue.

| | serialQueueConfiguration |

Additional configuration of internal serial dispatch queue.

| | leeway |

The amount of time, in nanoseconds, that the system will defer the timer.

|

`

                init(queue:internalSerialQueueName:leeway:)
                `

Constructs new SerialDispatchQueueScheduler named internalSerialQueueName that wraps queue.

Declaration

Swift

public convenience init(queue: DispatchQueue, internalSerialQueueName: String, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0))

Parameters

| queue |

Possibly concurrent dispatch queue used to perform work.

| | internalSerialQueueName |

Name of internal serial dispatch queue proxy.

| | leeway |

The amount of time, in nanoseconds, that the system will defer the timer.

|

`

                init(qos:internalSerialQueueName:leeway:)
                `

Constructs new SerialDispatchQueueScheduler that wraps one of the global concurrent dispatch queues.

Declaration

Swift

@available(macOS 10.10, *)
public convenience init(qos: DispatchQoS, internalSerialQueueName: String = "rx.global_dispatch_queue.serial", leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0))

Parameters

| qos |

Identifier for global dispatch queue with specified quality of service class.

| | internalSerialQueueName |

Custom name for internal serial dispatch queue proxy.

| | leeway |

The amount of time, in nanoseconds, that the system will defer the timer.

|

`

                schedule(_:action:)
                `

Schedules an action to be executed immediately.

Declaration

Swift

public final func schedule<StateType>(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable

Parameters

| state |

State passed to the action to be executed.

| | action |

Action to be executed.

|

Return Value

The disposable object used to cancel the scheduled action (best effort).

`

                scheduleRelative(_:dueTime:action:)
                `

Schedules an action to be executed.

Declaration

Swift

public final func scheduleRelative<StateType>(_ state: StateType, dueTime: RxTimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable

Parameters

| state |

State passed to the action to be executed.

| | dueTime |

Relative time after which to execute the action.

| | action |

Action to be executed.

|

Return Value

The disposable object used to cancel the scheduled action (best effort).

`

                schedulePeriodic(_:startAfter:period:action:)
                `

Schedules a periodic piece of work.

Declaration

Swift

public func schedulePeriodic<StateType>(_ state: StateType, startAfter: RxTimeInterval, period: RxTimeInterval, action: @escaping (StateType) -> StateType) -> Disposable

Parameters

| state |

State passed to the action to be executed.

| | startAfter |

Period after which initial work should be run.

| | period |

Period for running the work periodically.

| | action |

Action to be executed.

|

Return Value

The disposable object used to cancel the scheduled action (best effort).