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)) 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;
bool read(T &value)
Read the value through the COROUTINE_AWAIT() macro or the COROUTINE_CHANNEL_READ() macro...
void setValue(const T &value)
Used by COROUTINE_CHANNEL_WRITE() to preserve the value of the write across multiple COROUTINE_YIELD(...
All coroutines are instances of the Coroutine base class.
An unbuffered synchronized channel.
bool write(const T &value)
Write the given value to the channel through the COROUTINE_AWAIT() if value is a static variable...
bool write()
Same as write(constT& value) except use the value of setValue().