zpp
Zephyr C++20 Framework
main.cpp File Reference
#include <zephyr/ztest.h>
#include <zephyr/kernel.h>
#include <zpp/timer.hpp>
#include <zpp/thread.hpp>
#include <zpp/fmt.hpp>
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

 ZTEST_SUITE (zpp_timer_tests, NULL, NULL, NULL, NULL, NULL)
 
 ZTEST (zpp_timer_tests, test_timer_creation_function)
 
 ZTEST (zpp_timer_tests, test_timer_creation_lambda)
 

Function Documentation

◆ ZTEST() [1/2]

ZTEST ( zpp_timer_tests  ,
test_timer_creation_function   
)

Definition at line 28 of file main.cpp.

29 {
30  using namespace zpp;
31  using namespace std::chrono;
32 
33  auto t = make_timer(timer_callback);
34  t.start(100ms, 1s);
35 
37 }
auto sleep_for(const std::chrono::duration< T_Rep, T_Period > &sleep_duration)
Suspend the current thread for a specified time duration.
Definition: thread.hpp:77
auto make_timer() noexcept
create sync_timer object
Definition: timer.hpp:233

References zpp::make_timer(), and zpp::this_thread::sleep_for().

◆ ZTEST() [2/2]

ZTEST ( zpp_timer_tests  ,
test_timer_creation_lambda   
)

Definition at line 39 of file main.cpp.

40 {
41  using namespace zpp;
42  using namespace std::chrono;
43 
44  auto t = make_timer(
45  [] (auto t) {
46  print("Hello from timer tid={}\n",
48  } );
49 
50  t.start(100ms, 1s);
51 
53 }
auto get_id() noexcept
Get the thread ID of the current thread.
Definition: thread.hpp:42
void print(const char *fmt, T_Args &&... args) noexcept
simple typesafe print function
Definition: fmt.hpp:157

References zpp::this_thread::get_id(), zpp::make_timer(), zpp::print(), and zpp::this_thread::sleep_for().

◆ ZTEST_SUITE()

ZTEST_SUITE ( zpp_timer_tests  ,
NULL  ,
NULL  ,
NULL  ,
NULL  ,
NULL   
)