Interface IReactiveScheduler<TKey>
Represents a scheduler of IScheduleTask<TKey> instances.
public interface IReactiveScheduler<TKey> : IDisposable where TKey : notnull
Type Parameters
TKeyTask key type.
- Inherited Members
Properties
DefaultInterval
Maximum Duration to hang the underlying time tracking mechanism for.
Duration DefaultInterval { get; }
Property Value
KeyComparer
Key equality comparer.
IEqualityComparer<TKey> KeyComparer { get; }
Property Value
- IEqualityComparer<TKey>
SpinWaitDurationHint
SpinWait duration hint for the underlying time tracking mechanism.
Duration SpinWaitDurationHint { get; }
Property Value
StartTimestamp
Timestamp of creation of this scheduler.
Timestamp StartTimestamp { get; }
Property Value
State
Specifies the current state of this scheduler.
ReactiveSchedulerState State { get; }
Property Value
TaskKeys
Collection of registered task keys.
IReadOnlyCollection<TKey> TaskKeys { get; }
Property Value
- IReadOnlyCollection<TKey>
Timestamps
ITimestampProvider instance used for time tracking.
ITimestampProvider Timestamps { get; }
Property Value
Methods
Clear()
Removes and disposes all currently registered tasks.
void Clear()
MakeInfinite(TKey)
Attempts to make the task associated with the specified key repeat infinitely.
bool MakeInfinite(TKey key)
Parameters
keyTKeyTask key.
Returns
- bool
true when task was updated, otherwise false.
Remove(TKey)
Attempts to remove and dispose a task with the specified key.
bool Remove(TKey key)
Parameters
keyTKeyKey to remove.
Returns
- bool
true when task was removed, otherwise false.
Schedule(IScheduleTask<TKey>, Timestamp)
Attempts to schedule the provided task.
bool Schedule(IScheduleTask<TKey> task, Timestamp timestamp)
Parameters
taskIScheduleTask<TKey>Task to schedule.
timestampTimestampTimestamp that specifies when the scheduled task should be invoked.
Returns
- bool
true when task was scheduled, otherwise false.
Remarks
When task key already exists, then the entry will be updated only if the key is associated exactly
with the provided task and it is not in the process of being disposed.
Schedule(IScheduleTask<TKey>, Timestamp, Duration, int)
Attempts to schedule the provided task that repeats the specified number of times.
bool Schedule(IScheduleTask<TKey> task, Timestamp firstTimestamp, Duration interval, int repetitions)
Parameters
taskIScheduleTask<TKey>Task to schedule.
firstTimestampTimestampTimestamp that specifies when the scheduled task should be invoked for the first time.
intervalDurationInterval between subsequent task invocations.
repetitionsintNumber of repetitions.
Returns
- bool
true when task was scheduled, otherwise false.
Remarks
When task key already exists, then the entry will be updated only if the key is associated exactly
with the provided task and it is not in the process of being disposed.
Exceptions
- ArgumentOutOfRangeException
When
intervalis less than 1 tick.
ScheduleInfinite(IScheduleTask<TKey>, Timestamp, Duration)
Attempts to schedule the provided task that repeats infinitely.
bool ScheduleInfinite(IScheduleTask<TKey> task, Timestamp firstTimestamp, Duration interval)
Parameters
taskIScheduleTask<TKey>Task to schedule.
firstTimestampTimestampTimestamp that specifies when the scheduled task should be invoked for the first time.
intervalDurationInterval between subsequent task invocations.
Returns
- bool
true when task was scheduled, otherwise false.
Remarks
When task key already exists, then the entry will be updated only if the key is associated exactly
with the provided task and it is not in the process of being disposed.
Exceptions
- ArgumentOutOfRangeException
When
intervalis less than 1 tick.
SetInterval(TKey, Duration)
Attempts to change the interval of the task associated with the specified key.
bool SetInterval(TKey key, Duration interval)
Parameters
keyTKeyTask key.
intervalDurationInterval between subsequent task invocations.
Returns
- bool
true when task was updated, otherwise false.
Exceptions
- ArgumentOutOfRangeException
When
intervalis less than 1 tick.
SetNextTimestamp(TKey, Timestamp)
Attempts to change the next timestamp of the task associated with the specified key.
bool SetNextTimestamp(TKey key, Timestamp timestamp)
Parameters
keyTKeyTask key.
timestampTimestampTimestamp that specifies when the scheduled task should be invoked next.
Returns
- bool
true when task was updated, otherwise false.
SetRepetitions(TKey, int)
Attempts to change the number of repetitions of the task associated with the specified key.
bool SetRepetitions(TKey key, int repetitions)
Parameters
keyTKeyTask key.
repetitionsintNumber of repetitions.
Returns
- bool
true when task was updated, otherwise false.
Exceptions
- ArgumentOutOfRangeException
When
repetitionsis less than 1.
Start()
Starts this scheduler synchronously. Does nothing when this scheduler has already been started.
void Start()
StartAsync(TaskScheduler?)
Starts this scheduler asynchronously.
Task StartAsync(TaskScheduler? scheduler = null)
Parameters
schedulerTaskSchedulerOptional task scheduler.
Returns
- Task
New Task instance that completes when this scheduler is done or CompletedTask when this scheduler has already been started.
TryGetTaskState(TKey)
Attempts to create a ScheduleTaskState<TKey> instance for the given task key.
[Pure]
ScheduleTaskState<TKey>? TryGetTaskState(TKey key)
Parameters
keyTKeyTask key to create a snapshot for.
Returns
- ScheduleTaskState<TKey>
New ScheduleTaskState<TKey> instance or null when task does not exist.