RACQueueScheduler Class Reference
Inherits from | RACScheduler : NSObject |
Declared in | RACQueueScheduler.h RACQueueScheduler.m |
Overview
An abstract scheduler which asynchronously enqueues all its work to a Grand Central Dispatch queue.
Because RACQueueScheduler is abstract, it should not be instantiated
directly. Create a subclass using the RACQueueScheduler+Subclass.h
interface and use that instead.
An interface for use by subclasses.
Subclasses should use performAsCurrentScheduler:
to do the actual block
invocation so that [RACScheduler currentScheduler] behaves as expected.
Note that RACSchedulers are expected to be serial. Subclasses must honor
that contract. See RACTargetQueueScheduler
for a queue-based scheduler
which will enforce the serialization guarantee.
Tasks
Other Methods
-
– initWithName:queue:
-
+ wallTimeWithDate:
-
– schedule:
-
– after:schedule:
-
– after:repeatingEvery:withLeeway:schedule:
-
– performAsCurrentScheduler:
Extension Methods
-
queue
property
Instance Methods
after:repeatingEvery:withLeeway:schedule:
Reschedule the given block at a particular interval, starting at a specific time, and with a given leeway for deferral.
- (RACDisposable *)after:(NSDate *)date repeatingEvery:(NSTimeInterval)interval withLeeway:(NSTimeInterval)leeway schedule:(void ( ^ ) ( void ))block
Discussion
Note that blocks scheduled for a certain time will not preempt any other scheduled work that is executing at the time.
Regardless of the value of leeway
, the given block may not execute exactly
at when
or exactly on successive intervals, whether due to system load or
because another block is currently being run on the scheduler.
It is considered undefined behavior to invoke this method on the immediateScheduler.
date - The earliest time at which block
should begin executing. The
block may not execute immediately at this time, whether due to
system load or another block on the scheduler currently being
run. Cannot be nil.
interval - The interval at which the block should be rescheduled, starting
from date
. This will use the system wall clock, to avoid
skew when the computer goes to sleep.
leeway - A hint to the system indicating the number of seconds that each
scheduling can be deferred. Note that this is just a hint, and
there may be some additional latency no matter what.
block - The block to repeatedly schedule for execution. Cannot be nil.
Returns a disposable which can be used to cancel the automatic scheduling and rescheduling, or nil if cancellation is not supported.
Declared In
RACScheduler.h
after:schedule:
Schedule the given block for execution on the scheduler at or after a specific time.
- (RACDisposable *)after:(NSDate *)date schedule:(void ( ^ ) ( void ))block
Discussion
Note that blocks scheduled for a certain time will not preempt any other scheduled work that is executing at the time.
When invoked on the immediateScheduler, the calling thread will block until the specified time.
date - The earliest time at which block
should begin executing. The block
may not execute immediately at this time, whether due to system load
or another block on the scheduler currently being run. Cannot be nil.
block - The block to schedule for execution. Cannot be nil.
Returns a disposable which can be used to cancel the scheduled block before it begins executing, or nil if cancellation is not supported.
Declared In
RACScheduler.h
initWithName:queue:
Initializes the receiver with the name of the scheduler and the queue which the scheduler should use.
- (id)initWithName:(NSString *)name queue:(dispatch_queue_t)queue
Discussion
name - The name of the scheduler. If nil, a default name will be used. queue - The queue upon which the receiver should enqueue scheduled blocks. This argument must not be NULL.
Returns the initialized object.
Declared In
RACQueueScheduler+Subclass.h
performAsCurrentScheduler:
Performs the given block with the receiver as the current scheduler for
queue
. This should only be called by subclasses to perform scheduled blocks
on their queue.
- (void)performAsCurrentScheduler:(void ( ^ ) ( void ))block
Discussion
block - The block to execute. Cannot be NULL.
Declared In
RACQueueScheduler+Subclass.h
schedule:
Schedule the given block for execution on the scheduler.
- (RACDisposable *)schedule:(void ( ^ ) ( void ))block
Discussion
Scheduled blocks will be executed in the order in which they were scheduled.
block - The block to schedule for execution. Cannot be nil.
Returns a disposable which can be used to cancel the scheduled block before it begins executing, or nil if cancellation is not supported.
Declared In
RACScheduler.h