Table of Contents

Interface IReactiveScheduler<TKey>

Namespace
LfrlAnvil.Reactive.Chrono
Assembly
LfrlAnvil.Reactive.Chrono.dll

Represents a scheduler of IScheduleTask<TKey> instances.

public interface IReactiveScheduler<TKey> : IDisposable where TKey : notnull

Type Parameters

TKey

Task key type.

Inherited Members

Properties

DefaultInterval

Maximum Duration to hang the underlying time tracking mechanism for.

Duration DefaultInterval { get; }

Property Value

Duration

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

Duration

StartTimestamp

Timestamp of creation of this scheduler.

Timestamp StartTimestamp { get; }

Property Value

Timestamp

State

Specifies the current state of this scheduler.

ReactiveSchedulerState State { get; }

Property Value

ReactiveSchedulerState

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

ITimestampProvider

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

key TKey

Task 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

key TKey

Key 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

task IScheduleTask<TKey>

Task to schedule.

timestamp Timestamp

Timestamp 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

task IScheduleTask<TKey>

Task to schedule.

firstTimestamp Timestamp

Timestamp that specifies when the scheduled task should be invoked for the first time.

interval Duration

Interval between subsequent task invocations.

repetitions int

Number 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 interval is 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

task IScheduleTask<TKey>

Task to schedule.

firstTimestamp Timestamp

Timestamp that specifies when the scheduled task should be invoked for the first time.

interval Duration

Interval 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 interval is 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

key TKey

Task key.

interval Duration

Interval between subsequent task invocations.

Returns

bool

true when task was updated, otherwise false.

Exceptions

ArgumentOutOfRangeException

When interval is 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

key TKey

Task key.

timestamp Timestamp

Timestamp 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

key TKey

Task key.

repetitions int

Number of repetitions.

Returns

bool

true when task was updated, otherwise false.

Exceptions

ArgumentOutOfRangeException

When repetitions is 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

scheduler TaskScheduler

Optional 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

key TKey

Task key to create a snapshot for.

Returns

ScheduleTaskState<TKey>

New ScheduleTaskState<TKey> instance or null when task does not exist.