Navigating the API
poco aims to provide all the bare neccessities for a coroutine library. At a glance, it consists of the basic coroutine operations, and a minimal set of corotuine and scheduler aware primitives for synchronisation and communication.
The table below provides a quick reference to the available primitives and their functions. These are organised based on the execution context they are designed for. Details about the specific functions and their usage can be found in the respective sections.
To get the best use out of the APIs, there are a few naming conventions used to help navigate the available functions.
Function Variants
Synchronization primitives (queues, semaphores, events, etc.) expose up to
3 variants of each operation. These are designed to apply to a variety of execution
contexts.
Danger
Incorrect usage of each variants may yield undefined or unexpected behaviour. Ensure the variant in use is correct for your specific execution context.
These include 2 general use forms, and a special form:
a plain form,
a
*_from_isrform, anda
*_no_waitform.
Some primitives may have all 3, whereas some may only have 1 or 2.
The plain form is designed for use within coroutines.
For primitives that support use within an ISR, the *_from_isr should be used. The
ISR variants use a special scheduler based notification system to report events. These
variants will return a special code result::RES_NOTIFY_FAILED when the
scheduler has insufficient storage in its event buffer to queue up the event.
When creating a scheduler, ensure the event buffer is set up to handle the maximum number of interrupts between the worst case coroutine yield.
The additional form *_no_wait is provided for advanced use cases and are designed
for coroutine use where yielding is not desired. As no yielding is performed, these
consume the same scheduler event buffer as the *_from_isr variants. Care must be
taken ensure sufficient slots are available for the expected use case.