Mark3 Realtime Kernel
Mark3::Coroutine Class Reference

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>

Inheritance diagram for Mark3::Coroutine:
Mark3::TypedLinkListNode< Coroutine > Mark3::LinkListNode

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...
 

Private Attributes

CoListm_pclOwner
 
CoroutineHandler m_pfHandler
 
void * m_pvContext
 
PORT_PRIO_TYPE m_uPriority
 
bool m_bQueued
 

Additional Inherited Members

Detailed Description

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.

Examples:
lab2_coroutines/main.cpp.

Definition at line 53 of file coroutine.h.

Constructor & Destructor Documentation

◆ ~Coroutine()

Mark3::Coroutine::~Coroutine ( )

Definition at line 28 of file coroutine.cpp.

Member Function Documentation

◆ Activate()

void Mark3::Coroutine::Activate ( )

Activate Tag the co-routine as pending execution. Has no effect if the co-routine is already pending execution.

Examples:
lab2_coroutines/main.cpp.

Definition at line 67 of file coroutine.cpp.

◆ GetPriority()

PORT_PRIO_TYPE Mark3::Coroutine::GetPriority ( )

GetPriority Retrieve the current scheduling priority of the co-routine.

Returns
current scheduling priority of the co-routine.

Definition at line 97 of file coroutine.cpp.

◆ Init()

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.

Parameters
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.

◆ operator new()

void* Mark3::Coroutine::operator new ( size_t  sz,
void *  pv 
)
inline

Definition at line 56 of file coroutine.h.

◆ Run()

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.

◆ SetPriority()

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.

Parameters
uPriority_New priority of the co-routine

Definition at line 82 of file coroutine.cpp.

Member Data Documentation

◆ m_bQueued

bool Mark3::Coroutine::m_bQueued
private

Definition at line 108 of file coroutine.h.

◆ m_pclOwner

CoList* Mark3::Coroutine::m_pclOwner
private

Definition at line 104 of file coroutine.h.

◆ m_pfHandler

CoroutineHandler Mark3::Coroutine::m_pfHandler
private

Definition at line 105 of file coroutine.h.

◆ m_pvContext

void* Mark3::Coroutine::m_pvContext
private

Definition at line 106 of file coroutine.h.

◆ m_uPriority

PORT_PRIO_TYPE Mark3::Coroutine::m_uPriority
private

Definition at line 107 of file coroutine.h.


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