Class Metronome<T>
The primitive regular-tick clock source. Emits a T
value at a fixed Interval. Each emission corresponds to a
tick: T values can carry the wall-time (e.g. a
DateTimeOffset) or a sequence number projected to any
T the consumer needs.
public sealed class Metronome<T> : IClock<T>, IObservable<T> where T : struct, IComparable<T>
Type Parameters
TTime representation emitted by this clock. See IClock<T>.
- Inheritance
-
Metronome<T>
- Implements
-
IClock<T>IObservable<T>
- Inherited Members
Remarks
The user-facing abstraction is IClock<T>. The
Metronome is a regular-tick implementation. For "induced by
actions" scenarios (e.g. backtest replay), the test driver emits via
a System.Reactive.Subjects.Subject<T> cast to IClock<T> instead of
using a Metronome.
Constructors
Metronome(TimeSpan, Func<long, T>)
Construct a metronome that emits T at interval.
The projection maps the tick sequence number (0, 1, 2, ...)
to a T value.
public Metronome(TimeSpan interval, Func<long, T> projection)
Parameters
intervalTimeSpanTime between emissions. Must be > Zero.
projectionFunc<long, T>Maps the sequence number to a T value.
Exceptions
- ArgumentOutOfRangeException
intervalis <= Zero.
Properties
Interval
Time between emissions. Must be > Zero.
public TimeSpan Interval { get; }
Property Value
Methods
Subscribe(IObserver<T>)
Notifies the provider that an observer is to receive notifications.
public IDisposable Subscribe(IObserver<T> observer)
Parameters
observerIObserver<T>The object that is to receive notifications.
Returns
- IDisposable
A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them.