réplica de
https://github.com/tearshark/librf.git
synced 2024-10-04 08:50:31 +08:00
21 líneas
464 B
C++
21 líneas
464 B
C++
#include "librf/librf.h"
|
|
|
|
namespace librf
|
|
{
|
|
LIBRF_API future_t<> sleep_until_(std::chrono::system_clock::time_point tp_, scheduler_t& scheduler_)
|
|
{
|
|
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();
|
|
}
|
|
}
|