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, IAsyncDisposable where TKey : notnull

Type Parameters

TKey

Task key type.

Inherited Members

Properties

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

TaskDisposalTimeout

Max time the disposal of scheduled tasks will wait for their invocations to complete.

Duration TaskDisposalTimeout { get; }

Property Value

Duration

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()

Attempts to start this scheduler.

bool Start()

Returns

bool

false when scheduler was not started because it was not in Created state, otherwise true.

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.