#include <source/ariba/utility/transport/tcpip/protlib/threads.h>
Inherited by protlib::TimerModule, protlib::TPoverTCP, and protlib::TPoverUDP.
Public Types | |
enum | state_t { STATE_INIT, STATE_RUN, STATE_STOP, STATE_ABORT } |
Public Member Functions | |
Thread (const ThreadParam &p, bool create_queue=true, bool exp_allow=true) | |
virtual | ~Thread () |
void * | start_processing () |
void | stop_processing (bool do_lock=true) |
void | abort_processing (bool do_lock=true) |
bool | is_running (bool do_lock=true) |
virtual void | main_loop (uint32 thread_num)=0 |
void | lock () |
void | unlock () |
void | signal_cond () |
void | broadcast_cond () |
void | wait_cond () |
int | wait_cond (const struct timespec &ts) |
int | wait_cond (int32 sec, int32 nsec=0) |
state_t | get_state (bool do_lock=true) |
FastQueue * | get_fqueue () |
Static Public Member Functions | |
static void | get_time_of_day (struct timespec &ts) |
get time of day as timespec | |
Private Member Functions | |
void | inc_running_threads () |
void | dec_running_threads () |
uint32 | get_running_threads () const |
void | inc_started_threads () |
uint32 | get_started_threads () const |
Private Attributes | |
uint32 | running_threads |
This counter records the number of threads running on this object. | |
uint32 | started_threads |
This counter records the number of started threads. | |
pthread_mutex_t | mutex |
pthread_cond_t | cond |
thread object condition | |
state_t | state |
thread state | |
const ThreadParam | tparam |
Thread parameters. | |
FastQueue * | fq |
The input queue where threads can get messages from. |
Don't confuse this Thread class with POSIX threads. A Thread class only provides a main_loop method which will be executed by one or more POSIX threads simultaneously. The Thread instance provides a central point for all those POSIX threads to store data. Don't forget to lock() the Thread instance to avoid race conditions if you want to access and/or modify the data.
Definition at line 136 of file threads.h.
FastQueue* protlib::Thread::get_fqueue | ( | ) | [inline] |
Definition at line 171 of file threads.h.
References fq.
Referenced by protlib::TPoverTCP::main_loop(), and protlib::TimerModule::TimerModule().
virtual void protlib::Thread::main_loop | ( | uint32 | thread_num | ) | [pure virtual] |
Implemented in protlib::TimerModule, protlib::TPoverTCP, and protlib::TPoverUDP.
Referenced by start_processing().
pthread_cond_t protlib::Thread::cond [private] |
thread object condition
Definition at line 191 of file threads.h.
Referenced by broadcast_cond(), signal_cond(), Thread(), wait_cond(), and ~Thread().
FastQueue* protlib::Thread::fq [private] |
The input queue where threads can get messages from.
Definition at line 200 of file threads.h.
Referenced by get_fqueue(), protlib::TPoverTCP::main_loop(), protlib::TimerModule::process_queue(), protlib::TPoverTCP::sender_thread(), and ~Thread().
pthread_mutex_t protlib::Thread::mutex [private] |
uint32 protlib::Thread::running_threads [private] |
This counter records the number of threads running on this object.
Definition at line 177 of file threads.h.
Referenced by dec_running_threads(), get_running_threads(), and inc_running_threads().
uint32 protlib::Thread::started_threads [private] |
This counter records the number of started threads.
Definition at line 180 of file threads.h.
Referenced by get_started_threads(), and inc_started_threads().
state_t protlib::Thread::state [private] |
thread state
Definition at line 194 of file threads.h.
Referenced by abort_processing(), get_state(), start_processing(), and stop_processing().
const ThreadParam protlib::Thread::tparam [private] |
Thread parameters.
Definition at line 197 of file threads.h.
Referenced by lock(), and start_processing().