#include <platform_timer.hpp>
Definition at line 14 of file platform_timer.hpp.
◆ platform_timer()
sysio::chain::platform_timer::platform_timer |
( |
| ) |
|
Definition at line 24 of file platform_timer_asio_fallback.cpp.
24 {
25 static_assert(sizeof(impl) <= fwd_size);
26
27 std::lock_guard guard(timer_ref_mutex);
28
29 if(refcount++ == 0) {
31 checktime_thread = std::thread([&
p]() {
33 checktime_ios = std::make_unique<boost::asio::io_service>();
34 boost::asio::io_service::work work(*checktime_ios);
36
37 checktime_ios->run();
38 });
40 }
41
42 my->timer = std::make_unique<boost::asio::high_resolution_timer>(*checktime_ios);
43
44
45}
void set_os_thread_name(const string &name)
◆ ~platform_timer()
sysio::chain::platform_timer::~platform_timer |
( |
| ) |
|
Definition at line 47 of file platform_timer_asio_fallback.cpp.
47 {
49 if(std::lock_guard guard(timer_ref_mutex); --refcount == 0) {
50 checktime_ios->stop();
51 checktime_thread.join();
52 checktime_ios.reset();
53 }
54}
◆ set_expiration_callback()
void sysio::chain::platform_timer::set_expiration_callback |
( |
void(* | func )(void *), |
|
|
void * | user ) |
|
inline |
Definition at line 24 of file platform_timer.hpp.
24 {
25 bool expect_false = false;
26 while(!atomic_compare_exchange_strong(&_callback_variables_busy, &expect_false, true))
27 expect_false = false;
29 _callback_variables_busy.store(false, std::memory_order_release);
30 });
31 SYS_ASSERT(!(func && _expiration_callback), misc_exception,
"Setting a platform_timer callback when one already exists");
32
33 _expiration_callback =
func;
34 _expiration_callback_data =
user;
35 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
scoped_exit< Callback > make_scoped_exit(Callback &&c)
◆ start()
Definition at line 56 of file platform_timer_asio_fallback.cpp.
56 {
59 return;
60 }
64 else {
65#if 0
67 checktime_ios->post([&
p,
this]() {
70 });
72#endif
74 my->timer->expires_after(std::chrono::microseconds(x.
count()));
75 my->timer->async_wait([this](const boost::system::error_code& ec) {
76 if(ec)
77 return;
79 call_expiration_callback();
80 });
81 }
82}
constexpr int64_t count() const
constexpr const microseconds & time_since_epoch() const
static constexpr time_point maximum()
◆ stop()
void sysio::chain::platform_timer::stop |
( |
| ) |
|
◆ expired
std::atomic_bool sysio::chain::platform_timer::expired = true |
The documentation for this struct was generated from the following files: