#include <setjmp.h>
Go to the source code of this file.
◆ DOUBLE_STACK_COROUTINE_ARGUMENTS_BUFFER_SIZE
| #define DOUBLE_STACK_COROUTINE_ARGUMENTS_BUFFER_SIZE 8 |
This class implements a coroutine with its own stack.
The coroutine implementation:
- Makes it possible to stop the coroutine half way a function, and resume from there later.
- Is used by the microapp, so that blocking calls can be used in the microapp code, without blocking bluenet.
- Uses setjmp and longjmp to jump back and forth. Max buffer size for coroutine arguments.
◆ coroutine_function_t
| typedef void(* coroutine_function_t) (void *) |
◆ getCoroutineArgumentBuffer()
| uint8_t * getCoroutineArgumentBuffer |
( |
| ) |
|
Get the coroutine argument buffer.
◆ initCoroutine()
| int initCoroutine |
( |
coroutine_function_t |
coroutineFunction, |
|
|
void * |
argument, |
|
|
uint8_t |
argumentSize, |
|
|
const uintptr_t |
ramEnd |
|
) |
| |
Initialize the coroutine.
Make sure to first set the coroutine arguments.
- Parameters
-
| [in] | coroutineFunction | The first function of the coroutine to be executed. |
| [in] | argument | The argument for the coroutine function, this will be copied, and can be retrieved again with getCoroutineArgumentBuffer(). |
| [in] | argumentSize | Size of the argument. |
| [in] | ramEnd | Pointer to the end of the ram reserved for this coroutine. |
- Returns
- 0 on success.
◆ resumeCoroutine()
Resume the coroutine.
- Returns
- 0 When the coroutine finished.
◆ yieldCoroutine()
Yield the coroutine: resume in bluenet.