Bare Metal Programming Tool Kit
|
rtos private implementation class More...
#include <rtos.h>
Public Member Functions | |
pool (const char *name="") | |
construct a pool, specify its name (for debgging only) | |
void | write (T item) |
atomic write operation on a pool | |
T | read (void) |
atomic read operation on a pool | |
rtos private implementation class
place to store and retrieve data, no built-in synchronisation A (communication) pool is a template class that stores a single value. It supports the read and write operations, which are guaranteed to be atomic. (On a non-preemptive rtos every assignment is atomic, but the pool template is still usefull to make it explicit that data is transferred between tasks.)
The example below demonstrates the use of a pool to maintain a seconds-since-startup counter. Note that the call RTOS::runtime() returns the time elapsed since startup, so there is no need to maintain a seconds-since-startup this way yourself.
<< code >> make it an example
|
inline |
|
inline |
atomic read operation on a pool
A read operation returns the most recently written data.In the context of co-operative multitasking a read of write operation on anything is always atomic, unless the implementation of that operating somehow invokes the rtos. But for clearness it is a good idea to implement such task-global data as pools.
|
inline |
atomic write operation on a pool
A read operation returns the most recently written data.
In the context of co-operative multitasking a read of write operation on anything is always atomic, unless the implementation of that operating somehow invokes the rtos. But for clearness it is a good idea to implement such task-global data as pools.