ark::pipeline::EventTimer

Defined in header “ark/pipeline/event_timer.hh”.


This timer allows you to register events that will occur at some point in the future essentially allowing you to schedule events at a custom/dynamic frequency.

Methods

  • EventTimer(EventTimerFunction function, std::string name)
    Constructor. Initialize a timer with the specified function.

  • ~EventTimer()
    Virtual destructor, for cleanup.

  • void reset_to_time(const std::chrono::steady_clock::time_point & time)
    Resets the timer to the given timestamp. No executions will occur, and future ticks/elapsed calls will be relative to this timestamp. All elapsed time will be erased.

  • bool tick(const std::chrono::steady_clock::time_point & now)
    Called periodically with the current clock (virtual or otherwise). This will register the times that a timer should execute, so that downstream code can take care of executing them.

    Returns true if execute() will need to be invoked, false otherwise.

  • size_t queue_size()
    Returns the number of executions remaining (the number of times you can invoke execute()).

  • bool pop(TimerWorkItem & item)
    Pops the oldest execution off the queue and returns a work item. This is the first phase of execution, allowing you to deterministically pop an execution time off the timer, and execute it in a background thread.

    Returns true if the pop was successful, false if the queue is empty.

  • void execute_work_item(TimerWorkItem && item)
    The second half of timer execution. Consumes the given timer work item as received from pop(), taking ownership of it, and then invokes the callback.

  • bool execute()
    Pops the oldest execution off the queue and executes the callback against it. Returns true if something was executed, or false otherwise.

  • std::chrono::nanoseconds time_remaining(const std::chrono::steady_clock::time_point & now)
    Returns the amount of time left before the next execution, based on the given timestamp.

  • TimerStatistics statistics()
    Returns statistics related to this timer.

  • TimerCallbackTimings timings()
    Returns timing information related to this timer’s callback. Resets the timing information after this call (so the maximums are reset). This API is meant to be called periodically to determine the max timing information over some period of time.

  • std::chrono::nanoseconds configured_expected_runtime()
    Returns the configured execution time for this timer.

  • std::chrono::nanoseconds expected_runtime(const TimerWorkItem & item)
    Returns the expected runtime as if this timer had executed the given work item.

  • std::string name()
    Returns the human-readable name assigned to the timer.