timertt-1.2.0
2017.10.27
We have updated our timertt library to version 1.2.0. The significant changes are:
We broke compatibility with previous versions. It means that switching from timertt-1.1.* to 1.2.* may require some code rewriting. We have also removed support for some old compilers (like VS2013).
An user can now specify a type of timer action as a template parameter for timer_thread and timer_manager templates. Previous versions treat timers actions as std::function
class operation_canceler {
operation_manager & manager_;
operation_id id_;
public:
operation_canceler(operation_manager & manager, operation_id id)
: manager_{manager}, id_{id}
{}
void operator()() const noexcept
{
manager_.cancel(id_);
}
};
...
// Define type of timer thread which was use operation_canceler as
// a timer action type.
using my_timer_wheel_thread = timertt::timer_wheel_thread_template<
operation_canceler,
timertt::default_error_logger,
timertt::default_actor_exception_handler >;
...
// Create and use this timer thread.
my_timer_wheel_thread tt;
tt.start();
...
tt.activate( std::chrono::milliseconds(750), operation_canceler{manager, current_id});
New types scoped_timer_objects which allows creation of timer objects on the stack or as part of other objects. This avoids allocation/deallocation of timer objects in the heap, but requires more attention from the developers.
void do_something_complex() {
timertt::default_timer_wheel_thread tt;
tt.start();
...
timertt::default_timer_wheel_thread::scoped_timer_object timer;
// Activate
tt.activate(timer, std::chrono::milliseconds(250), ...);
...
// Timer can be deactivated in usual way.
tt.deactivate(timer);
...
tt.shutdown_and_join();
}