#include <AP_Thread.h>
Inherited by AMICO_Layer, AMICO_Link, AMICO_Receiver, AMICO_link, AMICO_link_accept, AP_ActiveObject, AP_Debugger, AP_Logger, AP_MemoryPool, CarLinO_core, CarLinO_leash, CarLinO_process, GOAL_Manager, my_application, OrientationChaser, and TimeSensor.
Public Member Functions | |
AP_Thread (AP_Uint32 stacksize=AP_MEDIUM_STACK) | |
AP_Bool | isRunning (void) const |
void | kill (void) |
virtual void | run (void) |
void | sleepme (AP_Sint32 timeout) |
Sleep the thread. It hangs the thread on a posix semaphore. | |
bool | spawn (const AP_Byte *name="", const AP_Byte *description="") |
void | stop (void) |
void | wait (void) |
void | wakeup (void) |
Wakeup the thread. It wakeup the thread that is waiting on a posix semaphore. | |
virtual | ~AP_Thread () |
Static Public Member Functions | |
static void * | wrapper (void *object) |
Protected Attributes | |
AP_Byte | _m_description [AP_TEXT_SIZE] |
AP_Bool | _m_running |
AP_ThreadObject | _m_thread |
AP_ThreadObjectAttr | _m_threadAttr |
AP_Byte | _m_threadName [AP_NAME_SIZE] |
AP_Bool | _m_wakeup |
_thread | thread handle of type pthread_t | |
_mutex | mutex posix for thread sections critical | |
_sleep | posix semaphore for sleep/wakeup thread function | |
_running | flag for thread running state (true = running, false = stopped) | |
_locked | flag for thread section critical notify (true = inside critical section, false = out of critical section) |
~AP_Thread | ( | void | ) | [virtual] |
Distructor of class. It notifies the stop to run method and kill the thread. The distructor waits for the thread termination before exit.
AP_Bool isRunning | ( | void | ) | const [inline] |
Status of the thread. It return the running status of thread. Used in the main loop (run) of the thread.
void kill | ( | void | ) |
Kill thread function. It notifies the stop to main function (run), kill the thread and wait for thread termination.
virtual void run | ( | void | ) | [inline, virtual] |
Main thread function. It must be overloaded in your derived class. It has no parameter.
Example:
void run(void)
{
while(is_running())
{
... do something ...
}
}
Reimplemented in AMICO_link_accept, AMICO_link, AP_ActiveObject, AP_Logger, AP_MemoryPool, CarLinO_core, CarLinO_leash, CarLinO_process, GOAL_Manager, my_application, OrientationChaser, TimeSensor, AMICO_Layer, AMICO_MemoryLink, AMICO_Receiver, and AMICO_SocketLink.
void sleepme | ( | AP_Sint32 | timeout | ) |
Sleep the thread. It hangs the thread on a posix semaphore.
Spawn thread function. It creates the thread and launches it.
void stop | ( | void | ) |
void wait | ( | void | ) |
void wakeup | ( | void | ) |
Wakeup the thread. It wakeup the thread that is waiting on a posix semaphore.
void * wrapper | ( | void * | object | ) | [static] |
AP_Byte _m_description[AP_TEXT_SIZE] [protected] |
AP_Bool _m_running [protected] |
AP_ThreadObject _m_thread [protected] |
AP_ThreadObjectAttr _m_threadAttr [protected] |
AP_Byte _m_threadName[AP_NAME_SIZE] [protected] |