TunableClock

@interface TunableClock : ClockBase

A clock whose tick offset and speed can be adjusted on the fly. Must be based on another clock, a parent clock. A tunable clock specifies a correlation relationship with respect to its parent clock. This correlation specifies a tick value, a tick rate and a speed value for this clock and a tick value from the parent clock as from which this relationship applies.

Advancement of time of this clock is based on the tick count and rates reported by the supplied parent clock. If you adjust the tickRate or speed, then the change is applied going forward from the moment it is made. E.g. if you are observing the rate of increase of the ticks property, then doubling the speed wil cause the ticks property to start increasing faster but will not cause it to suddenly jump value.

  • Last tick value of parent clock from which tickRate and speed applies

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) int64_t lastTicks;

    Swift

    var lastTicks: Int64 { get set }
  • Start tick count for this clock

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) int64_t startTicks;

    Swift

    var startTicks: Int64 { get set }
  • This clock’s slew

    Declaration

    Objective-C

    @property (getter=slew, assign, readwrite, nonatomic) int64_t slew;

    Swift

    var slew: Int64 { get set }
  • Default-value init method disallowed. Use initWithParentClock() method instead.

    Declaration

    Objective-C

    - (instancetype)init;
  • Initialise a tunable clock instance.

    Declaration

    Objective-C

    - (instancetype)initWithParentClock:(ClockBase *)parentClock
                               TickRate:(uint64_t)tickRate
                                  Ticks:(int64_t)ticks;

    Swift

    init!(parentClock: ClockBase!, tickRate: UInt64, ticks: Int64)

    Parameters

    parentClock

    parent clock used for advancement of time in this current clock

    tickRate

    A frequency/tick rate in ticks per second for thic clock

    ticks

    The starting tick count for this clock

    Return Value

    a tunable clock instance

  • Rebase correlation of this tunable clock (with the parent clock) to the parent’s clock current tick value.

    Declaration

    Objective-C

    - (void)rebase;

    Swift

    func rebase()
  • Change the tick value of this clock by a specified offset value

    Declaration

    Objective-C

    - (void)adjustTicks:(int64_t)offset;

    Swift

    func adjustTicks(_ offset: Int64)

    Parameters

    offset

    offset tick value

  • Change the time value of this clock by a specified offset value

    Declaration

    Objective-C

    - (void)adjustTimeNanos:(int64_t)offset_nanos;

    Swift

    func adjustTimeNanos(_ offset_nanos: Int64)

    Parameters

    offset_nanos

    offset in nanoseconds

  • Change the time value of this clock by a specified offset value and update the error value of this clock as well as the rate at which this error grows.

    Declaration

    Objective-C

    - (void)adjustTimeNanos:(int64_t)offset_nanos
            WithStaticError:(int64_t)staticErrorNanos
               AndErrorRate:(int32_t)errorRatePPM;

    Swift

    func adjustTimeNanos(_ offset_nanos: Int64, withStaticError staticErrorNanos: Int64, andErrorRate errorRatePPM: Int32)

    Parameters

    offset_nanos

    offset in nanoseconds

    staticErrorNanos

    a static error value in nanoseconds for this clock.

    errorRatePPM

    the rate at which this clock’s error grows