protlib::Thread Class Reference
[Threads]

#include <source/ariba/utility/transport/tcpip/protlib/threads.h>

Inherited by protlib::TimerModule, protlib::TPoverTCP, and protlib::TPoverUDP.

Collaboration diagram for protlib::Thread:

Collaboration graph
[legend]

List of all members.

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)
FastQueueget_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.
FastQueuefq
 The input queue where threads can get messages from.


Detailed Description

Abstract interface for thread modules.

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.


Member Enumeration Documentation

State of a thread.

The state of a thread does not really tell whether there are threads active or not. It only represents a state in the life cycle of a thread object.

Enumerator:
STATE_INIT 
STATE_RUN 
STATE_STOP 
STATE_ABORT 

Definition at line 166 of file threads.h.


Member Function Documentation

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]


Member Data Documentation

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

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]

Thread-global mutex.

This mutex is used to lock the thread object when data common to all threads on this object is modified.

Definition at line 188 of file threads.h.

Referenced by lock(), Thread(), unlock(), wait_cond(), and ~Thread().

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

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

thread state

Definition at line 194 of file threads.h.

Referenced by abort_processing(), get_state(), start_processing(), and stop_processing().

Thread parameters.

Definition at line 197 of file threads.h.

Referenced by lock(), and start_processing().


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

Generated on Fri Aug 14 23:39:53 2009 for Ariba by  doxygen 1.5.8