Queues and schedulers
There are built-in scheduler types that work with Grand Central Dispatch (GCD) queues and NSOperationQueues
, including SerialDispatchQueueScheduler
, which can dispatch work on a specified serial dispatch queue; ConcurrentDispatchQueueScheduler
, which will dispatch on a concurrent dispatch queue; and OperationQueueScheduler
, which will perform the work on a specifiedNSOperationQueues
.
We can also specify our own custom schedulers by conforming to the immediateScheduler
protocol.
Scheduler Singletons
There are a couple of Singleton schedulers that we can use for some common needs such as the following:
CurrentThreadScheduler
MainScheduler
CurrentThreadScheduler
represents the current thread and is the default scheduler. The MainScheduler
, on the other hand, represents the main thread and is typically used for all UI-related work.
Specifying a scheduler
To specify a scheduler on which a subscription is created, handler-executed, and disposed of, we use the subscribeOn
operator...