61 fprintf(stderr,
"%3.3d dog is watching: Since last ping %" PRIi64
" us\n", ping_count++, td.
to_num_of(1_us));
71 fprintf(stderr,
"test01_dog1: start\n");
72 REQUIRE( 0 == ping_count );
75 const bool r = periodic_dog.
start(dog_period,
jau::bind_member(
this, &TestSimpleTimer01::dog_watch_func));
84 REQUIRE( td <= test_period + 50_ms );
91 REQUIRE(
true == periodic_dog.
stop() );
93 REQUIRE( td <= 100_ms );
95 fprintf(stderr,
"test01_dog1: stopped\n");
98 REQUIRE( 0 < ping_count );
105 fprintf(stderr,
"test01_dog2: start\n");
106 REQUIRE( 0 == ping_count );
107 REQUIRE(
false == periodic_dog.
is_running() );
109 const bool r = periodic_dog.
start(dog_period,
jau::bind_member(
this, &TestSimpleTimer01::dog_watch_func));
110 REQUIRE(
true == r );
112 REQUIRE(
false == periodic_dog.
shall_stop() );
118 REQUIRE( td <= test_period + 50_ms );
121 REQUIRE(
false == periodic_dog.
shall_stop() );
125 REQUIRE(
true == periodic_dog.
stop() );
127 REQUIRE( td <= 100_ms );
129 fprintf(stderr,
"test01_dog2: stopped\n");
130 REQUIRE(
false == periodic_dog.
is_running() );
132 REQUIRE( 0 < ping_count );
const bool sighandler_once
constexpr int_type to_num_of(const fraction< int_type > &new_base, bool *overflow_ptr=nullptr) const noexcept
Converts this this fraction to a numerator for the given new base fraction.
static bool singleton_sighandler() noexcept
Install the singleton SIGALRM sighandler instance.
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.
bool stop() noexcept
Stop timer, see service_runner::stop()
bool shall_stop() const noexcept
Returns true if timer shall stop.
bool is_running() const noexcept
Returns true if timer is running.
std::string to_string(const alphabet &v) noexcept
bool to_fraction_i64(fraction_i64 &result, const std::string &value, const fraction_i64 &min_allowed, const fraction_i64 &max_allowed) noexcept
Stores the fraction_i64 value of the given string value in format <num>/<denom>, which may contain wh...
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...
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
bool sleep_for(const fraction_timespec &relative_time, const bool monotonic=true, const bool ignore_irq=true) noexcept
sleep_for causes the current thread to block until a specific amount of time has passed.
Timespec structure using int64_t for its components in analogy to struct timespec_t on 64-bit platfor...
METHOD_AS_TEST_CASE(TestSimpleTimer01::test01_dog1, "Test TestSimpleTimer01 - test01_dog1")