AceRoutine  1.2.1
A low-memory, fast-switching, cooperative multitasking library using stackless coroutines on Arduino platforms.
Public Member Functions | List of all members
ace_routine::Channel< T > Class Template Reference

An unbuffered synchronized channel. More...

#include <Channel.h>

Public Member Functions

 Channel ()
 Constructor.
 
void setValue (const T &value)
 Used by COROUTINE_CHANNEL_WRITE() to preserve the value of the write across multiple COROUTINE_YIELD() calls. More...
 
bool write ()
 Same as write(constT& value) except use the value of setValue(). More...
 
bool write (const T &value)
 Write the given value to the channel through the COROUTINE_AWAIT() if value is a static variable.
 
bool read (T &value)
 Read the value through the COROUTINE_AWAIT() macro or the COROUTINE_CHANNEL_READ() macro.
 

Detailed Description

template<typename T>
class ace_routine::Channel< T >

An unbuffered synchronized channel.

Readers and writers block until the writer is ready to send and the receiver is ready to receive. Then the writer writes, the reader reads, reader continues processing, then the writer continues processing. This sequencing is implemented as a finite state machine.

The result of sending 20 integers from the writer to the reader looks like this:

Writer: sending 0
Reader: received 0
Writer: sending 1
Reader: received 1
Writer: sending 2
Reader: received 2
...

This sequence of events matches the user's expectations.

Definition at line 43 of file Channel.h.

Member Function Documentation

◆ setValue()

template<typename T >
void ace_routine::Channel< T >::setValue ( const T &  value)
inline

Used by COROUTINE_CHANNEL_WRITE() to preserve the value of the write across multiple COROUTINE_YIELD() calls.

Not designed to be used directly by the user.

Definition at line 53 of file Channel.h.

◆ write()

template<typename T >
bool ace_routine::Channel< T >::write ( )
inline

Same as write(constT& value) except use the value of setValue().

Used by COROUTINE_CHANNEL_WRITE() macro. Not designed to be used directly by the user.

Definition at line 62 of file Channel.h.


The documentation for this class was generated from the following file: