31#include <jau/test/catch2_ext.hpp>
61 fprintf(stderr,
"%3.3d dog is watching: Since last ping %" PRIi64
" us\n", ping_count++, td.
to_num_of(1_us));
69 INFO_STR(
"\n\ntest01\n");
71 fprintf(stderr,
"test01_dog1: start\n");
72 REQUIRE( 0 == ping_count );
73 REQUIRE(
false == periodic_dog.is_running() );
74 REQUIRE(
true == periodic_dog.shall_stop() );
75 const bool r = periodic_dog.start(dog_period,
jau::bind_member(
this, &TestSimpleTimer01::dog_watch_func));
77 REQUIRE(
true == periodic_dog.is_running() );
78 REQUIRE(
false == periodic_dog.shall_stop() );
84 REQUIRE( td <= test_period + 50_ms );
86 REQUIRE(
true == periodic_dog.is_running() );
87 REQUIRE(
false == periodic_dog.shall_stop() );
91 REQUIRE(
true == periodic_dog.stop() );
93 REQUIRE( td <= 100_ms );
95 fprintf(stderr,
"test01_dog1: stopped\n");
96 REQUIRE(
false == periodic_dog.is_running() );
97 REQUIRE(
true == periodic_dog.shall_stop() );
98 REQUIRE( 0 < ping_count );
103 INFO_STR(
"\n\ntest01\n");
105 fprintf(stderr,
"test01_dog2: start\n");
106 REQUIRE( 0 == ping_count );
107 REQUIRE(
false == periodic_dog.is_running() );
108 REQUIRE(
true == periodic_dog.shall_stop() );
109 const bool r = periodic_dog.start(dog_period,
jau::bind_member(
this, &TestSimpleTimer01::dog_watch_func));
110 REQUIRE(
true == r );
111 REQUIRE(
true == periodic_dog.is_running() );
112 REQUIRE(
false == periodic_dog.shall_stop() );
118 REQUIRE( td <= test_period + 50_ms );
120 REQUIRE(
true == periodic_dog.is_running() );
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() );
131 REQUIRE(
true == periodic_dog.shall_stop() );
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 shall_stop() const noexcept
Returns true if timer shall stop.
ordered_atomic< int, std::memory_order_seq_cst > sc_atomic_int
SC atomic integral scalar integer.
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.
fraction< int64_t > fraction_i64
fraction using int64_t as integral type
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")