Mark3 Realtime Kernel
|
The Coroutine class implements a lightweight, run-to-completion task that forms the basis for co-operative task scheduling in Mark3. Coroutines are designed to be run from a singular context, and scheduled as a result of events occurring from threads, timers, interrupt sources, or other co-routines. More...
#include <coroutine.h>
Public Member Functions | |
void * | operator new (size_t sz, void *pv) |
~Coroutine () | |
void | Init (PORT_PRIO_TYPE uPriority_, CoroutineHandler pfHandler_, void *pvContext_) |
Init Initialize the coroutine object prior to use. Must be called before using the other methods in the class. More... | |
void | Run () |
Run Clear the co-routine's pending execution flag, and execute the coroutine's handler function. More... | |
void | Activate () |
Activate Tag the co-routine as pending execution. Has no effect if the co-routine is already pending execution. More... | |
void | SetPriority (PORT_PRIO_TYPE uPriority_) |
SetPriority Update the scheduling priority of the co-routine. Can be called from within the co-routine, or from any other context aware of the co-routine object. More... | |
PORT_PRIO_TYPE | GetPriority () |
GetPriority Retrieve the current scheduling priority of the co-routine. More... | |
Public Member Functions inherited from Mark3::TypedLinkListNode< Coroutine > | |
Coroutine * | GetNext () |
Coroutine * | GetPrev () |
Public Member Functions inherited from Mark3::LinkListNode | |
LinkListNode * | GetNext (void) |
GetNext. More... | |
LinkListNode * | GetPrev (void) |
GetPrev. More... | |
Private Attributes | |
CoList * | m_pclOwner |
CoroutineHandler | m_pfHandler |
void * | m_pvContext |
PORT_PRIO_TYPE | m_uPriority |
bool | m_bQueued |
Additional Inherited Members | |
Protected Member Functions inherited from Mark3::LinkListNode | |
LinkListNode () | |
void | ClearNode () |
ClearNode. More... | |
Protected Attributes inherited from Mark3::LinkListNode | |
LinkListNode * | next |
Pointer to the next node in the list. More... | |
LinkListNode * | prev |
Pointer to the previous node in the list. More... | |
The Coroutine class implements a lightweight, run-to-completion task that forms the basis for co-operative task scheduling in Mark3. Coroutines are designed to be run from a singular context, and scheduled as a result of events occurring from threads, timers, interrupt sources, or other co-routines.
Co-routines differ from Threads in that they cannot block, and must run to completion before other (potentially higher-priority) co-routines block.
Definition at line 53 of file coroutine.h.
Mark3::Coroutine::~Coroutine | ( | ) |
Definition at line 28 of file coroutine.cpp.
void Mark3::Coroutine::Activate | ( | ) |
Activate Tag the co-routine as pending execution. Has no effect if the co-routine is already pending execution.
Definition at line 67 of file coroutine.cpp.
PORT_PRIO_TYPE Mark3::Coroutine::GetPriority | ( | ) |
GetPriority Retrieve the current scheduling priority of the co-routine.
Definition at line 97 of file coroutine.cpp.
void Mark3::Coroutine::Init | ( | PORT_PRIO_TYPE | uPriority_, |
CoroutineHandler | pfHandler_, | ||
void * | pvContext_ | ||
) |
Init Initialize the coroutine object prior to use. Must be called before using the other methods in the class.
uPriority_ | The scheduling priority of this coroutine as configured by the port. |
pfHandler_ | Function to run when the coroutine is executed |
pvContext_ | User-defined value passed into the handler function on execution |
Definition at line 39 of file coroutine.cpp.
|
inline |
Definition at line 56 of file coroutine.h.
void Mark3::Coroutine::Run | ( | ) |
Run Clear the co-routine's pending execution flag, and execute the coroutine's handler function.
Definition at line 53 of file coroutine.cpp.
void Mark3::Coroutine::SetPriority | ( | PORT_PRIO_TYPE | uPriority_ | ) |
SetPriority Update the scheduling priority of the co-routine. Can be called from within the co-routine, or from any other context aware of the co-routine object.
uPriority_ | New priority of the co-routine |
Definition at line 82 of file coroutine.cpp.
|
private |
Definition at line 108 of file coroutine.h.
|
private |
Definition at line 104 of file coroutine.h.
|
private |
Definition at line 105 of file coroutine.h.
|
private |
Definition at line 106 of file coroutine.h.
|
private |
Definition at line 107 of file coroutine.h.