1 #ifndef ACE_ROUTINE_CHANNEL
2 #define ACE_ROUTINE_CHANNEL
8 #define COROUTINE_CHANNEL_WRITE(channel, x) \
10 (channel).setValue(x); \
11 COROUTINE_AWAIT((channel).write()); \
15 #define COROUTINE_CHANNEL_READ(channel, x) \
16 COROUTINE_AWAIT((channel).read(x))
18 namespace ace_routine {
54 mValueToWrite = value;
63 switch (mChannelState) {
67 mValue = mValueToWrite;
68 mChannelState = kDataProduced;
73 mChannelState = kWriterReady;
85 switch (mChannelState) {
90 mChannelState = kDataProduced;
95 mChannelState = kWriterReady;
107 switch (mChannelState) {
109 mChannelState = kReaderReady;
115 mChannelState = kDataConsumed;
129 static const uint8_t kWriterReady = 0;
130 static const uint8_t kReaderReady = 1;
131 static const uint8_t kDataProduced = 2;
132 static const uint8_t kDataConsumed = 3;
134 uint8_t mChannelState = kWriterReady;