Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

lfc::Thread Class Reference

high level Thread class used for concurrency issues. More...

Inheritance diagram for lfc::Thread::

lfc::Object lfc::_Server lfc::_Named lfc::Application lfc::CallbackThread lfc::TimerThread List of all members.

Public Types

enum  State { stCreated, stRunning, stFinished, stInvalid }
enum  Priority { priorityMin = pal::threads::priorityMin, priorityNormal = pal::threads::priorityNormal, priorityMax = pal::threads::priorityMax }
 thread priority. More...


Public Methods

 Thread () throw ()
 creates a Thread. More...

virtual ~Thread () throw ()
virtual void start ()
 starts the Thread that calls it
Exceptions:
ThreadException  .
More...


virtual void destroy ()
 kills and destroys the Thread that calls it
Exceptions:
ThreadException  .
More...


virtual void cancel ()
 schedules this thread for cancellation. More...

virtual int join () const
 puts this thread on hold and waits for the other threads to finish execution. More...

virtual void setPriority (Priority priority)
virtual Priority priority () const
 the current priority. More...

virtual void setAutoDelete (bool bAutoDelete)
 sets the auto delete flag. More...

virtual State state () const throw ()
 the current state of the Thread. More...


Static Public Methods

void yield ()
 gives up temporarily to allow other threads to run
Exceptions:
ThreadException  .
More...


void sleep (long miliseconds)
 gives up execution and waits miliseconds before resuming. More...

Thread * self ()
 returns a pointer to self. More...

void exit (int exitCode=0)
 exits the program with exitCode returned to the system. More...

void testCancel (int exitCode=-1)
 checks the cancellation flag and if it's set cancels the Thread. More...

list< Thread *> threadsSnapshot ()
 returns a list of pointers to Threads still in existence. More...


Protected Methods

virtual void main ()=0
 the most important method of Thread You must override this method in your class that you derive from Thread. Whatever you put in this method is what gets executed when you call Thread::start(). More...


Static Protected Methods

void startRoutine (void *arg)
 helper function for starting the thread. More...


Protected Attributes

pal::threads::ThreadHandle m_handle
Priority m_priority
volatile State m_state
volatile bool m_bCancel
volatile int m_exitCode
volatile bool m_bAutoDelete
Mutex m_mutex

Static Protected Attributes

Mutex s_globalMutex
CurrentThreadTLS s_currentThreadTLS
list< Thread *> s_threadsList

Detailed Description

high level Thread class used for concurrency issues.


Member Enumeration Documentation

enum lfc::Thread::State
 

Enumeration values:
stCreated 
stRunning 
stFinished 
stInvalid 

enum lfc::Thread::Priority
 

thread priority.

Enumeration values:
priorityMin 
priorityNormal 
priorityMax 


Constructor & Destructor Documentation

lfc::Thread::Thread   throw ()
 

creates a Thread.

lfc::Thread::~Thread   throw () [virtual]
 


Member Function Documentation

void lfc::Thread::start   [virtual]
 

starts the Thread that calls it

Exceptions:
ThreadException  .

void lfc::Thread::destroy   [virtual]
 

kills and destroys the Thread that calls it

Exceptions:
ThreadException  .

void lfc::Thread::cancel   [virtual]
 

schedules this thread for cancellation.

int lfc::Thread::join   const [virtual]
 

puts this thread on hold and waits for the other threads to finish execution.

Returns:
exit state
Exceptions:
ThreadException 

void lfc::Thread::setPriority Priority    priority [virtual]
 

\bried sets the threads priority

Parameters:
priority  the priority to set the Thread to
Exceptions:
ThreadException 

virtual Priority lfc::Thread::priority   const [inline, virtual]
 

the current priority.

Returns:
the current Thread priority for the Thread that calls it

void lfc::Thread::setAutoDelete bool    bAutoDelete [virtual]
 

sets the auto delete flag.

Parameters:
bAutoDelete  if this is true the Thread deletes the object that got passed to Thread::startRoutine after it's done with it
See also:
Thread::startRoutine

virtual State lfc::Thread::state   const throw () [inline, virtual]
 

the current state of the Thread.

See also:
Thread::State

void lfc::Thread::yield   [static]
 

gives up temporarily to allow other threads to run

Exceptions:
ThreadException  .

void lfc::Thread::sleep long    miliseconds [static]
 

gives up execution and waits miliseconds before resuming.

Thread * lfc::Thread::self   [static]
 

returns a pointer to self.

See also:
Thread::CurrentThreadTLS

void lfc::Thread::exit int    exitCode = 0 [static]
 

exits the program with exitCode returned to the system.

void lfc::Thread::testCancel int    exitCode = -1 [static]
 

checks the cancellation flag and if it's set cancels the Thread.

list< Thread *> lfc::Thread::threadsSnapshot   [static]
 

returns a list of pointers to Threads still in existence.

virtual void lfc::Thread::main   [protected, pure virtual]
 

the most important method of Thread You must override this method in your class that you derive from Thread. Whatever you put in this method is what gets executed when you call Thread::start().

Reimplemented in lfc::CallbackThread, and lfc::TimerThread.

void lfc::Thread::startRoutine void *    arg [static, protected]
 

helper function for starting the thread.


Member Data Documentation

pal::threads::ThreadHandle lfc::Thread::m_handle [protected]
 

Priority lfc::Thread::m_priority [protected]
 

volatile State lfc::Thread::m_state [protected]
 

volatile bool lfc::Thread::m_bCancel [protected]
 

volatile int lfc::Thread::m_exitCode [protected]
 

volatile bool lfc::Thread::m_bAutoDelete [protected]
 

Mutex lfc::Thread::m_mutex [protected]
 

Mutex lfc::Thread::s_globalMutex [static, protected]
 

Thread::CurrentThreadTLS lfc::Thread::s_currentThreadTLS [static, protected]
 

list< Thread *> lfc::Thread::s_threadsList [static, protected]
 


The documentation for this class was generated from the following files:
Generated on Fri Jan 25 03:14:01 2002 for LFC2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001