38 std::cv_status s { std::cv_status::no_timeout };
39 while( !sr_ref.
shall_stop() && std::cv_status::timeout != s ) {
41 if( std::cv_status::timeout == s && !sr_ref.
shall_stop() ) {
48 std::unique_lock<std::mutex> lockReader(mtx_timerfunc);
62: timer_service(name, service_shutdown_timeout,
jau::bind_member(
this, &simple_timer::timer_work)),
63 timer_func(), duration()
70 timer_func = std::move(tofunc);
72 timer_service.start();
78 std::unique_lock<std::mutex> lockReader(mtx_timerfunc);
79 timer_func = std::move(tofunc);
82 timer_func = std::move(tofunc);
84 timer_service.start();
Service runner, a reusable dedicated thread performing custom user services.
std::mutex & mtx_shall_stop() noexcept
mtx_shall_stop() and cv_shall_stop() allows caller to be notified when shall_stop() changes,...
void set_shall_stop() noexcept
Marks the service thread to stop in due process by flagging shall stop to true.
std::condition_variable & cv_shall_stop() noexcept
mtx_shall_stop() and cv_shall_stop() allows caller to be notified when shall_stop() changes,...
bool shall_stop() const noexcept
Returns true if service shall stop.
bool start(const fraction_i64 &duration_, Timer_func tofunc) noexcept
Start the timer with given user Timer_func function and initial duration.
simple_timer(const std::string &name, const fraction_i64 &service_shutdown_timeout) noexcept
Constructs a new service.
function< fraction_i64(Timer0_ref)> Timer_func
User defined timer function using custom granularity via fraction_i64.
void start_or_update(const fraction_i64 &duration_, Timer_func tofunc) noexcept
Start or update the timer with given user Timer_func function and initial duration.
fraction_timespec getMonotonicTime() noexcept
Returns current monotonic time since Unix Epoch 00:00:00 UTC on 1970-01-01.
jau::function< R(A...)> bind_member(C1 *base, R(C0::*mfunc)(A...)) noexcept
Bind given class instance and non-void member function to an anonymous function using func_member_tar...
@ overflow
See FE_OVERFLOW.
constexpr const jau::fraction_i64 zero(0l, 1lu)
zero is 0/1
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
std::cv_status wait_until(std::condition_variable &cv, std::unique_lock< std::mutex > &lock, const fraction_timespec &absolute_time, const bool monotonic=true) noexcept
wait_until causes the current thread to block until the condition variable is notified,...
Timespec structure using int64_t for its components in analogy to struct timespec_t on 64-bit platfor...
CXX_ALWAYS_INLINE _Tp load() const noexcept