1
0
mirror of https://github.com/tearshark/librf.git synced 2024-10-01 15:57:07 +08:00
librf/source/sleep.cpp

21 lines
464 B
C++
Raw Normal View History

2021-11-01 17:59:08 +08:00
#include "librf/librf.h"
namespace librf
{
LIBRF_API future_t<> sleep_until_(std::chrono::system_clock::time_point tp_, scheduler_t& scheduler_)
2021-11-01 17:59:08 +08:00
{
awaitable_t<> awaitable;
(void)scheduler_.timer()->add(tp_,
[awaitable](bool cancellation_requested)
{
if (cancellation_requested)
awaitable.throw_exception(canceled_exception{ error_code::timer_canceled });
else
awaitable.set_value();
});
return awaitable.get_future();
}
}