Table of Contents

Class Metronome<T>

Namespace
Virtufin.Base.Clock
Assembly
Virtufin.Base.dll

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

T

Time representation emitted by this clock. See IClock<T>.

Inheritance
Metronome<T>
Implements
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

interval TimeSpan

Time between emissions. Must be > Zero.

projection Func<long, T>

Maps the sequence number to a T value.

Exceptions

ArgumentOutOfRangeException

interval is <= Zero.

Properties

Interval

Time between emissions. Must be > Zero.

public TimeSpan Interval { get; }

Property Value

TimeSpan

Methods

Subscribe(IObserver<T>)

Notifies the provider that an observer is to receive notifications.

public IDisposable Subscribe(IObserver<T> observer)

Parameters

observer IObserver<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.