Skip to content

Refactor task_timer to allow mocking the timer #884

@StefanoPetrilli

Description

@StefanoPetrilli

The class task_timer uses std::chrono::steady_clock. Currently, in the tests the real time has to elapse which makes running the test suite take much longer than it could because of the tests regarding this component.

I propose refactoring task_timer to something like:

template <typename ClockType = std::chrono::steady_clock>
class task_timer {
...
}

This would allow instantiating the task_timer using a mock timer and would allow replacing this_thread::sleep_for(chrono::seconds(4)); with something along the line of timer.advance(4); effectively making all the tests involving timers instant to execute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionThe viability / implementation of the issue is up for debatefeatureCode based project improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions