Class OperationQueue
- Namespace
- Punchclock
- Assembly
- Punchclock.dll
OperationQueue is the core of PunchClock, and represents a scheduler for deferred actions, such as network requests. This scheduler supports scheduling via priorities, as well as serializing requests that access the same data.
The queue allows a fixed number of concurrent in-flight operations at a time. When there are available "slots", items are dispatched as they come in. When the slots are full, the queueing policy starts to apply.
The queue, similar to Akavache's KeyedOperationQueue, also allows keys to be specified to serialize operations - if you have three "foo" items, they will wait in line and only one "foo" can run. However, a "bar" and "baz" item can run at the same time as a "foo" item.
- Inheritance
-
Operation
Queue
- Implements
- Extension Methods
Constructors
OperationQueue(int)
Initializes a new instance of the Operation
Parameters
maximumConcurrent
intThe maximum number of concurrent operations.
Methods
Dispose()
Dispose(bool)
Disposes managed resources that are disposable and handles cleanup of unmanaged items.
Parameters
isDisposing
boolIf we are disposing managed resources.
EnqueueObservableOperation<T>(int, Func<IObservable<T>>)
This method enqueues an action to be run at a later time, according to the scheduling policies (i.e. via priority).
public IObservable<T> EnqueueObservableOperation<T>(int priority, Func<IObservable<T>> asyncCalculationFunc)
Parameters
priority
intHigher priorities run before lower ones.
asyncCalculationFunc
Func<IObservable<T>>The async method to execute when scheduled.
Returns
- IObservable<T>
The result of the async calculation.
Type Parameters
T
The type of item for the observable.
EnqueueObservableOperation<T>(int, string, Func<IObservable<T>>)
This method enqueues an action to be run at a later time, according to the scheduling policies (i.e. via priority and key).
public IObservable<T> EnqueueObservableOperation<T>(int priority, string key, Func<IObservable<T>> asyncCalculationFunc)
Parameters
priority
intHigher priorities run before lower ones.
key
stringItems with the same key will be run in order.
asyncCalculationFunc
Func<IObservable<T>>The async method to execute when scheduled.
Returns
- IObservable<T>
The result of the async calculation.
Type Parameters
T
The type of item for the observable.
EnqueueObservableOperation<T, TDontCare>(int, string, IObservable<TDontCare>, Func<IObservable<T>>)
This method enqueues an action to be run at a later time, according to the scheduling policies (i.e. via priority and key).
public IObservable<T> EnqueueObservableOperation<T, TDontCare>(int priority, string key, IObservable<TDontCare> cancel, Func<IObservable<T>> asyncCalculationFunc)
Parameters
priority
intThe priority of operation. Higher priorities run before lower ones.
key
stringA key to apply to the operation. Items with the same key will be run in order.
cancel
IObservable<TDontCare>A observable which if signalled, the operation will be cancelled.
asyncCalculationFunc
Func<IObservable<T>>The async method to execute when scheduled.
Returns
- IObservable<T>
The result of the async calculation.
Type Parameters
T
The type of item for the observable.
TDontCare
Used to allow any observable type.
PauseQueue()
This method pauses the dispatch queue. Inflight operations will not be canceled, but new ones will not be processed until the queue is resumed.
Returns
- IDisposable
A Disposable that resumes the queue when disposed.
SetMaximumConcurrent(int)
Sets the maximum level of concurrency for the operation queue.
Parameters
maximumConcurrent
intThe maximum amount of concurrency.
ShutdownQueue()
Shuts down the queue and notifies when all outstanding items have been processed.
Returns
- IObservable<Unit>
An Observable that will signal when all items are complete.