Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ACS::ThreadManagerBase Class Reference

Manages a pool of ACS Base threads. More...

#include <acsThreadBase.h>

Inheritance diagram for ACS::ThreadManagerBase:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 ThreadManagerBase ()
 ~ThreadManagerBase ()
int getThreadCount () const
ACE_CString getThreadName (const int pos) const
ThreadBasegetThreadAt (const int pos) const
ThreadBasegetThreadByName (const ACE_CString &name)
ThreadBasegetThreadByID (ACE_thread_t id)
ThreadBasecreate (const ACE_CString &name, void *threadProc, void *parameter, const TimeInterval &responseTime=ThreadBase::defaultResponseTime, const TimeInterval &sleepTime=ThreadBase::defaultSleepTime, const long _thrFlags=THR_NEW_LWP|THR_DETACHED)
bool add (const ACE_CString &name, ThreadBase *acsBaseThread)
bool stop (const ACE_CString &name)
bool stopAll ()
void exit (const ACE_CString &name)
void exitAll ()
bool cancel (const ACE_CString &name)
bool cancelAll ()
bool terminate (const ACE_CString &name)
bool terminateAll ()
bool restart (const ACE_CString &name)
bool restartAll ()
bool restartDead ()
bool suspend (const ACE_CString &name)
bool suspendAll ()
bool resume (const ACE_CString &name)
bool resumeAll ()
bool isAlive (const ACE_CString &name)
bool areAllAlive ()
int join (const ACE_thread_t &tid)
ACE_Thread_Manager * getACEThreadManager ()

Protected Member Functions

void add2map (const ACE_CString &name, ThreadBase *thread)
void removeFromMap (const ACE_CString &name)

Protected Attributes

ACE_Recursive_Thread_Mutex m_addRemoveMutex
 mutex used by add and remove method

Private Member Functions

void operator= (const ThreadManagerBase &)
 ThreadManagerBase (const ThreadManagerBase &)

Private Attributes

ACE_Thread_Manager * threadManager_mp
 pointer to ACE_Threads_Manager
ThreadMap threadMap_m
 Thread name-thread map data store.
std::vector< ThreadBase * > threads_m
 Vector of all threads.

Detailed Description

Manages a pool of ACS Base threads.


Constructor & Destructor Documentation

ACS::ThreadManagerBase::ThreadManagerBase  )  [inline]
 

Constructor.

ACS::ThreadManagerBase::~ThreadManagerBase  ) 
 

Destructor. Also terminates and deletes all threads.

ACS::ThreadManagerBase::ThreadManagerBase const ThreadManagerBase  )  [private]
 

ALMA C++ coding standards state copy constructors should be disabled.


Member Function Documentation

bool ACS::ThreadManagerBase::add const ACE_CString &  name,
ThreadBase acsBaseThread
 

Add a thread to the ThreadBaseManger thread pool. WARNING: after this operation ThreadManagerBase owns the pointer of ThreadBase. ThreadBase object is deleted on destruction of ThreadManagerBase object. Therefore the given ThreadBase must have been allocated on the heap

Parameters:
name name of the thread
ThreadBase pointer to the thread

void ACS::ThreadManagerBase::add2map const ACE_CString &  name,
ThreadBase thread
[inline, protected]
 

Add a thread to the ThreadManagerBase data store.

Parameters:
name name of the thread
thread pointer to the thread

bool ACS::ThreadManagerBase::areAllAlive  ) 
 

Checks if all threads are alive (not terminated).

Parameters:
name name of the thread
Returns:
true if all threads are alive
See also:
ThreadManagerBase::isAlive

bool ACS::ThreadManagerBase::cancel const ACE_CString &  name  ) 
 

Cancel (forceful termination) named thread. Avoid using this kind of thread termination.

Parameters:
name name of the thread
See also:
ThreadBase::cancel

ThreadManagerBase::terminate

bool ACS::ThreadManagerBase::cancelAll  ) 
 

Cancel (forceful termination) all threads.

See also:
ThreadManagerBase::cancel

ThreadBase* ACS::ThreadManagerBase::create const ACE_CString &  name,
void *  threadProc,
void *  parameter,
const TimeInterval responseTime = ThreadBase::defaultResponseTime,
const TimeInterval sleepTime = ThreadBase::defaultSleepTime,
const long  _thrFlags = THR_NEW_LWP|THR_DETACHED
 

Create a new thread and add it to the pool. The thread is immediately created (create=true) and suspended

Parameters:
name of the thread
threadProc thread worker function
parameter an optional parameter to the thread
responseTime heartbeat response time in 100ns unit
sleepTime default sleep time in 100ns unit
_thrFlags Thread creation flags to be used if _create = TRUE. See ACE threads and pthread documentation for details. Default is now THR_NEW_LWP | THR_DETACHED
Returns:
pointer to ThreadBase object, NULL otherwise
See also:
ThreadBase

void ACS::ThreadManagerBase::exit const ACE_CString &  name  ) 
 

Notify named thread to exit thread worker function.

Parameters:
name name of the thread
See also:
ThreadBase::exit

void ACS::ThreadManagerBase::exitAll  ) 
 

Notify all the threads to exit thread worker function.

See also:
ThreadManagerBase::exit

ACE_Thread_Manager* ACS::ThreadManagerBase::getACEThreadManager  )  [inline]
 

Returns pointer to the ACE Thread Manager

Returns:
pointer to ACE_Thread_Manager object

ThreadBase* ACS::ThreadManagerBase::getThreadAt const int  pos  )  const [inline]
 

Get thread at the specified position.

Parameters:
pos position of the thread
Returns:
pointer to ThreadBase object

ThreadBase* ACS::ThreadManagerBase::getThreadByID ACE_thread_t  id  )  [inline]
 

Get thread with specified ID.

Parameters:
id ID of the thread
Returns:
pointer to ThreadBase object, NULL otherwise

ThreadBase* ACS::ThreadManagerBase::getThreadByName const ACE_CString &  name  )  [inline]
 

Get thread with specified named.

Parameters:
name name of the thread
Returns:
pointer to ThreadBase object, NULL otherwise

int ACS::ThreadManagerBase::getThreadCount  )  const [inline]
 

Get number of threads in the pool.

Returns:
number of threads in the pool

ACE_CString ACS::ThreadManagerBase::getThreadName const int  pos  )  const [inline]
 

Get name of the thread at the specified position.

Parameters:
pos position of the thread
Returns:
name of the thread

bool ACS::ThreadManagerBase::isAlive const ACE_CString &  name  ) 
 

Checks if named thread is alive (not terminated).

Parameters:
name name of the thread
Returns:
true if named thread is alive
See also:
ThreadBase::isAlive

int ACS::ThreadManagerBase::join const ACE_thread_t &  tid  ) 
 

join joinable thread

Parameters:
tid thread id
Returns:
-1 if fail

void ACS::ThreadManagerBase::operator= const ThreadManagerBase  )  [private]
 

ALMA C++ coding standards state assignment operators should be disabled.

void ACS::ThreadManagerBase::removeFromMap const ACE_CString &  name  )  [inline, protected]
 

bool ACS::ThreadManagerBase::restart const ACE_CString &  name  ) 
 

Restart named thread. Restarting means treminate and recreate a new thread.

Parameters:
name name of the thread
See also:
ThreadBase::restart

bool ACS::ThreadManagerBase::restartAll  ) 
 

Restart all threads.

See also:
ThreadManagerBase::restart

bool ACS::ThreadManagerBase::restartDead  ) 
 

Restart all dead threads, i.e. all terminated threads

See also:
ThreadManagerBase::restart

ThreadManagerBase::isAlive

bool ACS::ThreadManagerBase::resume const ACE_CString &  name  ) 
 

Continue the execution of a previously suspended thread.

Parameters:
name name of the thread
See also:
ThreadBase::resume

bool ACS::ThreadManagerBase::resumeAll  ) 
 

Continue the execution of all suspended threads.

See also:
ThreadManagerBase::resume

bool ACS::ThreadManagerBase::stop const ACE_CString &  name  ) 
 

Stop named thread.

Parameters:
name name of the thread
Returns:
true if thread has been stopped
See also:
ThreadBase::stop

bool ACS::ThreadManagerBase::stopAll  ) 
 

Stop all the threads_m.

Returns:
true if thread has been stopped
See also:
ThreadManagerBase::stop

bool ACS::ThreadManagerBase::suspend const ACE_CString &  name  ) 
 

Suspend the execution of a particular thread.

Parameters:
name name of the thread
See also:
ThreadBase::suspend

bool ACS::ThreadManagerBase::suspendAll  ) 
 

Suspend the execution of all running threads.

See also:
ThreadManagerBase::suspend

bool ACS::ThreadManagerBase::terminate const ACE_CString &  name  ) 
 

Terminate named thread.

Parameters:
name name of the thread
See also:
ThreadBase::terminate

bool ACS::ThreadManagerBase::terminateAll  ) 
 

Terminate all threads.

See also:
ThreadManagerBase::terminate


Member Data Documentation

ACE_Recursive_Thread_Mutex ACS::ThreadManagerBase::m_addRemoveMutex [protected]
 

mutex used by add and remove method

ACE_Thread_Manager* ACS::ThreadManagerBase::threadManager_mp [private]
 

pointer to ACE_Threads_Manager

ThreadMap ACS::ThreadManagerBase::threadMap_m [private]
 

Thread name-thread map data store.

std::vector<ThreadBase*> ACS::ThreadManagerBase::threads_m [private]
 

Vector of all threads.


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:37:00 2009 for ACS C++ API by doxygen 1.3.8