Debian Codegraph @

yo/coroutines/demo/fsa/done/done.h0

raw
1 #ifndef INCLUDED_DONE_
2 #define INCLUDED_DONE_
3
4 #include "../../promisebase/promisebase.h"
5 #include "../awaiter/awaiter.h"
6
7 class Done: public Awaiter
8 {
9 struct State: public PromiseBase<Done, State>
10 {
11 void return_void() const;
12 };
13
14 std::coroutine_handle<State> d_handle;
15 static size_t s_count;
16
17 public:
18 using promise_type = State;
19 using Handle = std::coroutine_handle<State>;
20
21 explicit Done(Handle handle);
22 ~Done();
23
24 template <typename HandleType>
25 std::coroutine_handle<State> await_suspend(HandleType const &handle);
26 };
27
28 template <typename HandleType>
29 std::coroutine_handle<Done::State> Done::await_suspend(
30 HandleType const &handle)
31 {
32 auto ret = d_handle;
33 d_handle = 0;
34 return ret;
35 }
36
37 inline void Done::State::return_void() const
38 {}
39
40 extern Done g_done;
41
42 #endif