9 std::shared_ptr<data::CancellableCallback> sleeped;
17 template <
class R,
class P>
20 dur(std::chrono::duration_cast<Duration>(dur)) {}
21 template <
class C,
class D>
24 constexpr void setExecutor(
ExecutorRef ex) { self.exec = ex; }
25 constexpr bool await_ready()
const noexcept {
return dur <= Duration{0}; }
26 void await_suspend(std::coroutine_handle<> handle) { self.sleeped = self.exec->executeAfter(handle, dur); }
27 constexpr void await_resume()
const noexcept {}
35 constexpr void setExecutor(
ExecutorRef ex) { self.exec = ex; }
36 constexpr bool await_ready()
const noexcept {
return false; }
37 void await_suspend(std::coroutine_handle<> handle) {
38 self.sleeped = std::make_shared<data::CancellableCallback>(handle);
40 constexpr void await_resume()
const noexcept {}
50 template <
class R,
class P>
51 DurAwaiter sleepFor(std::chrono::duration<R, P> duration) {
52 return {duration, *
this};
55 template <
class C,
class D>
56 DurAwaiter sleepUntil(std::chrono::time_point<C, D> time) {
60 EtnAwaiter sleep() {
return {*
this}; }
62 bool interrupt(
bool inplace =
false) {
63 if (
auto ptr = std::move(sleeped)) {
67 return ptr->moveTo([&](
auto&& f) {
68 exec->execute(std::move(f));