SObjectizer  5.7
Public Types | Public Member Functions | Protected Attributes | Private Types | List of all members
timertt::details::basic_methods_impl_mixin< Engine, Consumer > Class Template Reference

A implementation of basic methods for timer managers and timer threads. More...

#include <all.hpp>

Inheritance diagram for timertt::details::basic_methods_impl_mixin< Engine, Consumer >:

Public Types

using thread_safety = typename Engine::thread_safety
 A typedef for thread safety type from Engine. More...
 
using timer_action = typename Engine::timer_action
 An alias for timer_action type. More...
 
using scoped_timer_object = typename Engine::scoped_timer_object
 An alias for scoped timer objects. More...
 
using timer_holder = timer_object_holder< typename Engine::thread_safety >
 Shorthand for timer objects' smart pointer. More...
 

Public Member Functions

template<typename... Args>
 basic_methods_impl_mixin (Args &&... args)
 Constructor with all parameters. More...
 
timer_holder allocate ()
 Allocate of new timer object. More...
 
template<class Duration_1 >
void activate (timer_holder timer, Duration_1 pause, timer_action action)
 Activate timer and schedule it for execution. More...
 
template<class Duration_1 >
void reschedule (timer_holder timer, Duration_1 pause, timer_action action)
 Perform an attempt to reschedule a timer. More...
 
template<class Duration_1 >
void activate (scoped_timer_object &timer, Duration_1 pause, timer_action action)
 Activate a scoped timer and schedule it for execution. More...
 
template<class Duration_1 >
void activate (Duration_1 pause, timer_action action)
 Activate timer and schedule it for execution. More...
 
template<class Duration_1 , class Duration_2 >
void activate (timer_holder timer, Duration_1 pause, Duration_2 period, timer_action action)
 Activate timer and schedule it for execution. More...
 
template<class Duration_1 , class Duration_2 >
void reschedule (timer_holder timer, Duration_1 pause, Duration_2 period, timer_action action)
 Perform an attempt to reschedule a timer. More...
 
template<class Duration_1 , class Duration_2 >
void activate (scoped_timer_object &timer, Duration_1 pause, Duration_2 period, timer_action action)
 Activate a scoped timer and schedule it for execution. More...
 
template<class Duration_1 , class Duration_2 >
void activate (Duration_1 pause, Duration_2 period, timer_action action)
 Activate timer and schedule it for execution. More...
 
void deactivate (timer_holder timer)
 Deactivate timer and remove it from the list. More...
 
void deactivate (scoped_timer_object &timer)
 Deactivate timer and remove it from the list. More...
 
timer_quantities get_timer_quantities ()
 Count of timers of various types. More...
 
bool empty ()
 Check for emptiness. More...
 

Protected Attributes

Engine m_engine
 Actual timer engine instance. More...
 

Private Types

using mixin_type = typename mixin_selector< typename Engine::thread_safety, Consumer >::type
 Shorthand for actual mixin type. More...
 

Detailed Description

template<typename Engine, typename Consumer>
class timertt::details::basic_methods_impl_mixin< Engine, Consumer >

A implementation of basic methods for timer managers and timer threads.

Template Parameters
Engineactual type of engine to be used.
Consumertype of engine consumer (e.g. consumer_type::manager or consumer_type::thread).
Since
v.1.1.0

Member Typedef Documentation

◆ mixin_type

template<typename Engine, typename Consumer>
using timertt::details::basic_methods_impl_mixin< Engine, Consumer >::mixin_type = typename mixin_selector< typename Engine::thread_safety, Consumer >::type
private

Shorthand for actual mixin type.

◆ scoped_timer_object

template<typename Engine, typename Consumer>
using timertt::details::basic_methods_impl_mixin< Engine, Consumer >::scoped_timer_object = typename Engine::scoped_timer_object

An alias for scoped timer objects.

◆ thread_safety

template<typename Engine, typename Consumer>
using timertt::details::basic_methods_impl_mixin< Engine, Consumer >::thread_safety = typename Engine::thread_safety

A typedef for thread safety type from Engine.

Since
v.1.1.2

◆ timer_action

template<typename Engine, typename Consumer>
using timertt::details::basic_methods_impl_mixin< Engine, Consumer >::timer_action = typename Engine::timer_action

An alias for timer_action type.

◆ timer_holder

template<typename Engine, typename Consumer>
using timertt::details::basic_methods_impl_mixin< Engine, Consumer >::timer_holder = timer_object_holder< typename Engine::thread_safety >

Shorthand for timer objects' smart pointer.

Note
Since v.1.2.1 it is a public type name.

Constructor & Destructor Documentation

◆ basic_methods_impl_mixin()

template<typename Engine, typename Consumer>
template<typename... Args>
timertt::details::basic_methods_impl_mixin< Engine, Consumer >::basic_methods_impl_mixin ( Args &&...  args)
inline

Constructor with all parameters.

Member Function Documentation

◆ activate() [1/6]

template<typename Engine, typename Consumer>
template<class Duration_1 >
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::activate ( timer_holder  timer,
Duration_1  pause,
timer_action  action 
)
inline

Activate timer and schedule it for execution.

Exceptions
std::exceptionIf timer thread is not started.
std::exceptionIf timer is already activated.
Template Parameters
Duration_1actual type which represents time duration.
Parameters
timerTimer to be activated.
pausePause for timer execution.
actionAction for the timer.

◆ activate() [2/6]

template<typename Engine, typename Consumer>
template<class Duration_1 >
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::activate ( scoped_timer_object timer,
Duration_1  pause,
timer_action  action 
)
inline

Activate a scoped timer and schedule it for execution.

Note
A proper lifetime of this timer must be controlled by user.
Exceptions
std::exceptionIf timer thread is not started.
std::exceptionIf timer is already activated.
Template Parameters
Duration_1actual type which represents time duration.
Since
v.1.2.0
Parameters
timerTimer to be activated.
pausePause for timer execution.
actionAction for the timer.

◆ activate() [3/6]

template<typename Engine, typename Consumer>
template<class Duration_1 >
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::activate ( Duration_1  pause,
timer_action  action 
)
inline

Activate timer and schedule it for execution.

There is no need to preallocate timer object. It will be allocated automatically, but not be shown to user.

Exceptions
std::exceptionIf timer thread is not started.
Template Parameters
Duration_1actual type which represents time duration.
Parameters
pausePause for timer execution.
actionAction for the timer.

◆ activate() [4/6]

template<typename Engine, typename Consumer>
template<class Duration_1 , class Duration_2 >
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::activate ( timer_holder  timer,
Duration_1  pause,
Duration_2  period,
timer_action  action 
)
inline

Activate timer and schedule it for execution.

Exceptions
std::exceptionIf timer thread is not started.
std::exceptionIf timer is already activated.
Template Parameters
Duration_1actual type which represents time duration.
Duration_2actual type which represents time duration.
Parameters
timerTimer to be activated.
pausePause for timer execution.
periodRepetition period. If Duration_2::zero() == period then timer will be single-shot.
actionAction for the timer.

◆ activate() [5/6]

template<typename Engine, typename Consumer>
template<class Duration_1 , class Duration_2 >
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::activate ( scoped_timer_object timer,
Duration_1  pause,
Duration_2  period,
timer_action  action 
)
inline

Activate a scoped timer and schedule it for execution.

Note
A proper lifetime of this timer must be controlled by user.
Exceptions
std::exceptionIf timer thread is not started.
std::exceptionIf timer is already activated.
Template Parameters
Duration_1actual type which represents time duration.
Duration_2actual type which represents time duration.
Since
v.1.2.0
Parameters
timerTimer to be activated.
pausePause for timer execution.
periodRepetition period. If Duration_2::zero() == period then timer will be single-shot.
actionAction for the timer.

◆ activate() [6/6]

template<typename Engine, typename Consumer>
template<class Duration_1 , class Duration_2 >
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::activate ( Duration_1  pause,
Duration_2  period,
timer_action  action 
)
inline

Activate timer and schedule it for execution.

There is no need to preallocate timer object. It will be allocated automatically, but not be shown to user.

Exceptions
std::exceptionIf timer thread is not started.
Template Parameters
Duration_1actual type which represents time duration.
Duration_2actual type which represents time duration.
Parameters
pausePause for timer execution.
periodRepetition period. If Duration_2::zero() == period then timer will be single-shot.
actionAction for the timer.

◆ allocate()

template<typename Engine, typename Consumer>
timer_holder timertt::details::basic_methods_impl_mixin< Engine, Consumer >::allocate ( )
inline

Allocate of new timer object.

Note
This object must be activated by activate() methods.

◆ deactivate() [1/2]

template<typename Engine, typename Consumer>
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::deactivate ( timer_holder  timer)
inline

Deactivate timer and remove it from the list.

Parameters
timerTimer to be deactivated.

◆ deactivate() [2/2]

template<typename Engine, typename Consumer>
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::deactivate ( scoped_timer_object timer)
inline

Deactivate timer and remove it from the list.

Since
v.1.2.0
Parameters
timerTimer to be deactivated.

◆ empty()

template<typename Engine, typename Consumer>
bool timertt::details::basic_methods_impl_mixin< Engine, Consumer >::empty ( )
inline

Check for emptiness.

Since
v.1.1.3

◆ get_timer_quantities()

template<typename Engine, typename Consumer>
timer_quantities timertt::details::basic_methods_impl_mixin< Engine, Consumer >::get_timer_quantities ( )
inline

Count of timers of various types.

Note
This are quantities of all timers known to manager/thread. Some of them can be already deactivated but not removed yet.
Since
v.1.1.1

◆ reschedule() [1/2]

template<typename Engine, typename Consumer>
template<class Duration_1 >
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::reschedule ( timer_holder  timer,
Duration_1  pause,
timer_action  action 
)
inline

Perform an attempt to reschedule a timer.

Before v.1.2.1 there was just one way to reschedule a timer: method deactivate() must be called first and then method activate() must be called for the same timer. This approach is not fast because in the case of thread-safe engines it requires two operations on a mutex.

Since v.1.2.1 there is a reschedule() method which does deactivation of a timer (if it is active) and then new activation of this timer. All actions are performed by using just one operation on a mutex.

Note
This operation can fail if the timer to be rescheduled is in processing. Because of that it is recommended to use such operation for timer_managers only. But even with timer_managers this operation should be used with care.
Attention
It move operator for a timer_action throws then timer will be deactivated. The state for a timer_action itself will be unknown.
Exceptions
std::exceptionIf timer thread is not started.
std::exceptionIf timer is in processing right now.
Template Parameters
Duration_1actual type which represents time duration.
Since
v.1.2.1
Parameters
timerTimer to be rescheduled.
pausePause for timer execution.
actionAction for the timer.

◆ reschedule() [2/2]

template<typename Engine, typename Consumer>
template<class Duration_1 , class Duration_2 >
void timertt::details::basic_methods_impl_mixin< Engine, Consumer >::reschedule ( timer_holder  timer,
Duration_1  pause,
Duration_2  period,
timer_action  action 
)
inline

Perform an attempt to reschedule a timer.

Before v.1.2.1 there was just one way to reschedule a timer: method deactivate() must be called first and then method activate() must be called for the same timer. This approach is not fast because in the case of thread-safe engines it requires two operations on a mutex.

Since v.1.2.1 there is a reschedule() method which does deactivation of a timer (if it is active) and then new activation of this timer. All actions are performed by using just one operation on a mutex.

Note
This operation can fail if the timer to be rescheduled is in processing. Because of that it is recommended to use such operation for timer_managers only. But even with timer_managers this operation should be used with care.
Attention
It move operator for a timer_action throws then timer will be deactivated. The state for a timer_action itself will be unknown.
Exceptions
std::exceptionIf timer thread is not started.
std::exceptionIf timer is in processing right now.
Template Parameters
Duration_1actual type which represents time duration.
Duration_2actual type which represents time duration.
Since
v.1.2.1
Parameters
timerTimer to be activated.
pausePause for timer execution.
periodRepetition period. If Duration_2::zero() == period then timer will be single-shot.
actionAction for the timer.

Member Data Documentation

◆ m_engine

template<typename Engine, typename Consumer>
Engine timertt::details::basic_methods_impl_mixin< Engine, Consumer >::m_engine
protected

Actual timer engine instance.


The documentation for this class was generated from the following file: