#include <Actor.hh>
The Cosa Nucleo Actor; message passing supported thread.
Definition at line 31 of file Actor.hh.
Construct actor and initiate internals.
Definition at line 36 of file Actor.hh.
void Linkage::attach |
( |
Linkage * |
pred | ) |
|
|
inlineinherited |
Attach given linkage as predecessor. Will check and detach if already attached.
- Parameters
-
[in] | pred | linkage to attach. |
- Note
- atomic
Definition at line 71 of file Linkage.hh.
void Thread::begin |
( |
Thread * |
thread = NULL , |
|
|
size_t |
size = 0 |
|
) |
| |
|
staticinherited |
Schedule static thread with given stack size. Using the default parameters will start the main thread.
- Parameters
-
[in] | thread | to initiate and schedule. |
[in] | size | of stack. |
Definition at line 57 of file Thread.cpp.
void Thread::delay |
( |
uint32_t |
ms | ) |
|
|
inherited |
Delay at least the given time period in milli-seconds. The resolution is determined by the Watchdog clock and has a resolution of 16 milli-seconds (per tick). The actual delay also depends on how other threads yield.
- Parameters
-
[in] | ms | minimum delay time period in milli-seconds. |
Definition at line 121 of file Thread.cpp.
void Thread::dequeue |
( |
Head * |
queue, |
|
|
bool |
flag = true |
|
) |
| |
|
inherited |
If given queue is not empty dequeue first thread and resume direct if flag is true otherwise enqueue first in run queue.
- Parameters
-
[in] | queue | to transfer from. |
[in] | flag | resume direct otherwise on yield (Default true). |
Definition at line 107 of file Thread.cpp.
Detach this link. Unlink from any list.
Definition at line 125 of file Linkage.hh.
Enqueue running thread to given queue and yield.
- Parameters
-
[in] | queue | to transfer to. |
[in] | thread | to resume (Default yield). |
Definition at line 98 of file Thread.cpp.
void Thread::init |
( |
void * |
stack | ) |
|
|
protectedinherited |
Initiate thread and prepare for initial call to virtual member function run(). Stack frame is allocated by begin().
- Parameters
-
Definition at line 49 of file Thread.cpp.
virtual void Event::Handler::on_event |
( |
uint8_t |
type, |
|
|
uint16_t |
value |
|
) |
| |
|
inlinevirtualinherited |
Return predecessor in sequence.
- Returns
- predecessor linkage.
Definition at line 60 of file Linkage.hh.
int Actor::recv |
( |
Actor *& |
sender, |
|
|
uint8_t & |
port, |
|
|
void * |
buf = NULL , |
|
|
size_t |
size = 0 |
|
) |
| |
Receive message to given buffer and with given max size to actor. Returns sender, port and size or negative error code. Sending actor is rescheduled.
- Parameters
-
[in,out] | sender | actor. |
[in,out] | port | or message identity. |
[in] | buf | pointer to buffer (default NULL). |
[in] | size | of message (default 0) |
- Returns
- size or negative error code.
Definition at line 45 of file Actor.cpp.
void Thread::resume |
( |
Thread * |
thread | ) |
|
|
inherited |
Yield control to the given thread. Preserve stack and machine state and later continue.
- Parameters
-
Definition at line 90 of file Thread.cpp.
The thread main function. The function is called when the thread is scheduled and becomes running. Normally the function is an end-less loop. Returning from the function will result in that the function is called again. The default implementation is the main thread. It is responsible for power down when there are no other active threads. Other threads must override this member function.
Definition at line 72 of file Thread.cpp.
static Thread* Nucleo::Thread::running |
( |
| ) |
|
|
inlinestaticinherited |
Return running thread.
- Returns
- thread.
Definition at line 39 of file Thread.hh.
int Actor::send |
( |
uint8_t |
port, |
|
|
const void * |
buf = NULL , |
|
|
size_t |
size = 0 |
|
) |
| |
Send message in given buffer and with given size to actor. Given port may be used as message identity. Returns size or negative error code. Receiving actor is resumed.
- Parameters
-
[in] | port | or message identity. |
[in] | buf | pointer to buffer (default NULL). |
[in] | size | of message (default 0). |
- Returns
- size or negative error code.
Definition at line 26 of file Actor.cpp.
Service the nucleos main thread. Should be called in the loop() function.
Definition at line 133 of file Thread.cpp.
Return successor in sequence.
- Returns
- successor linkage.
Definition at line 51 of file Linkage.hh.
void Nucleo::Thread::yield |
( |
| ) |
|
|
inlineinherited |
Yield control to the next thread in the thread queue. Preserve stack and machine state and later continue.
Definition at line 75 of file Thread.hh.
const void* Nucleo::Actor::m_buf |
|
protected |
jmp_buf Nucleo::Thread::m_context |
|
protectedinherited |
uint32_t Nucleo::Thread::m_expires |
|
protectedinherited |
Delay time expires; should not run for more than 2**32 seconds.
Definition at line 133 of file Thread.hh.
uint8_t Nucleo::Actor::m_port |
|
protected |
volatile bool Nucleo::Actor::m_receiving |
|
protected |
Head Nucleo::Actor::m_sending |
|
protected |
size_t Nucleo::Actor::m_size |
|
protected |
Double linked list pointers.
Definition at line 93 of file Linkage.hh.
const size_t Nucleo::Thread::MAIN_STACK_MAX = 64 |
|
staticprotectedinherited |
Size of main thread stack.
Definition at line 115 of file Thread.hh.
Main thread and thread queue head.
Definition at line 121 of file Thread.hh.
Top of stack allocation.
Definition at line 127 of file Thread.hh.
The documentation for this class was generated from the following files: