20 template <
typename... Args>
21 Timer(std::chrono::milliseconds repeat_ms, Args&&... args) :
26 if ((rc = uv_timer_init(uv_default_loop(), &
uv_handle)) < 0)
28 LOG_FAIL_FMT(
"uv_timer_init failed: {}", uv_strerror(rc));
29 throw std::logic_error(
"uv_timer_init failed");
34 if ((rc = uv_timer_start(&
uv_handle, on_timer, 0, repeat_ms.count())) < 0)
36 LOG_FAIL_FMT(
"uv_timer_start failed: {}", uv_strerror(rc));
37 throw std::logic_error(
"uv_timer_start failed");
41 static void on_timer(uv_timer_t* handle)
43 static_cast<Timer*
>(
handle->data)->on_timer();