| 1 |
#ifndef INCLUDED_START_ |
| 2 |
#define INCLUDED_START_ |
| 3 |
|
| 4 |
#include "../../promisebase/promisebase.h" |
| 5 |
#include "../awaiter/awaiter.h" |
| 6 |
|
| 7 |
#include "../letter/letter.h" |
| 8 |
#include "../digit/digit.h" |
| 9 |
#include "../done/done.h" |
| 10 |
|
| 11 |
class Start: public Awaiter |
| 12 |
{ |
| 13 |
struct State: public PromiseBase<Start, State> |
| 14 |
{ |
| 15 |
template <typename NextState> |
| 16 |
NextState &await_transform(NextState &nextState) const; |
| 17 |
|
| 18 |
// Letter &await_transform(Letter &letter) const |
| 19 |
// { |
| 20 |
// return letter; |
| 21 |
// } |
| 22 |
// Digit &await_transform(Digit &digit) const |
| 23 |
// { |
| 24 |
// return digit; |
| 25 |
// } |
| 26 |
// Done &await_transform(Done &done) const |
| 27 |
// { |
| 28 |
// return done; |
| 29 |
|
| 30 |
}; |
| 31 |
|
| 32 |
std::coroutine_handle<State> d_handle; |
| 33 |
|
| 34 |
public: |
| 35 |
using promise_type = State; |
| 36 |
using Handle = std::coroutine_handle<State>; |
| 37 |
|
| 38 |
explicit Start(Handle handle); |
| 39 |
~Start(); |
| 40 |
|
| 41 |
void go(); |
| 42 |
|
| 43 |
template <typename HandleType> |
| 44 |
std::coroutine_handle<State> await_suspend(HandleType &handle); |
| 45 |
}; |
| 46 |
|
| 47 |
|
| 48 |
template <typename HandleType> |
| 49 |
std::coroutine_handle<Start::State> Start::await_suspend(HandleType &handle) |
| 50 |
{ |
| 51 |
auto ret = d_handle; |
| 52 |
d_handle = 0; |
| 53 |
return ret; |
| 54 |
} |
| 55 |
|
| 56 |
template <typename NextState> |
| 57 |
inline NextState &Start::State::await_transform(NextState &nextState) const |
| 58 |
{ |
| 59 |
return nextState; |
| 60 |
} |
| 61 |
|
| 62 |
extern Start g_start; |
| 63 |
|
| 64 |
#endif |