25#ifndef JAU_SIMPLE_TIMER_HPP_
26#define JAU_SIMPLE_TIMER_HPP_
30#include <condition_variable>
68 std::mutex mtx_timerfunc;
92 const std::string&
name() const noexcept {
return timer_service.
name(); }
136 bool stop() noexcept {
return timer_service.
stop(); }
Class template jau::function is a general-purpose static-polymorphic function wrapper.
Service runner, a reusable dedicated thread performing custom user services.
bool stop() noexcept
Stops this service, if running.
const std::string & name() const noexcept
Return the given name of this service.
bool is_running() const noexcept
Returns true if service is running.
pthread_t thread_id() const noexcept
Return the thread-id of this service service thread, zero if not running.
bool shall_stop() const noexcept
Returns true if service shall stop.
A simple timer for timeout and interval applications, using one dedicated service_runner thread per i...
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.
const std::string & name() const noexcept
Return the given name of this timer.
function< fraction_i64(Timer0_ref)> Timer_func
User defined timer function using custom granularity via fraction_i64.
bool stop() noexcept
Stop timer, see service_runner::stop()
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.
simple_timer(const simple_timer &o)=delete
No copy constructor nor move constructor.
simple_timer & Timer0_ref
pthread_t thread_id() const noexcept
Return the thread-id of this timer's worker thread, zero if not running.
bool shall_stop() const noexcept
Returns true if timer shall stop.
bool is_running() const noexcept
Returns true if timer is running.
fraction< int64_t > fraction_i64
fraction using int64_t as integral type
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.