OpenDDS
Snapshot(2023/04/07-19:43)
|
#include <ThreadPool.h>
Public Types | |
typedef ACE_THR_FUNC_RETURN(* | FunPtr) (void *) |
A typedef for the starting point of the ThreadPool. More... | |
Public Member Functions | |
ThreadPool (size_t count, FunPtr fun, void *arg=0) | |
virtual | ~ThreadPool () |
bool | contains (ACE_thread_t id) const |
Static Public Member Functions | |
static ACE_THR_FUNC_RETURN | run (void *arg) |
A static helper function used to redirect to requested thread start point. More... | |
Private Member Functions | |
void | join_all () |
OPENDDS_VECTOR (ACE_hthread_t) ids_ | |
OPENDDS_SET (ACE_thread_t) id_set_ | |
Private Attributes | |
FunPtr | fun_ |
void * | arg_ |
ACE_Thread_Mutex | mutex_ |
ConditionVariable< ACE_Thread_Mutex > | cv_ |
ThreadStatusManager | tsm_ |
size_t | active_threads_ |
ThreadPool is a light-weight utility class for starting a group of threads
ThreadPool creates several threads at construction and attempts to join them at destruction. Users of ThreadPool are responsible for making sure the running threads are in a joinable state before the destruction of ThreadPool
Definition at line 34 of file ThreadPool.h.
typedef ACE_THR_FUNC_RETURN(* OpenDDS::DCPS::ThreadPool::FunPtr) (void *) |
A typedef for the starting point of the ThreadPool.
Definition at line 39 of file ThreadPool.h.
OpenDDS::DCPS::ThreadPool::ThreadPool | ( | size_t | count, |
FunPtr | fun, | ||
void * | arg = 0 |
||
) |
Creates a ThreadPool with the specifed size, starting point, and argument
count | number of threads |
fun | starting point for the threads of the ThreadPool |
arg | an optional argument to pass to the starting function |
Definition at line 22 of file ThreadPool.cpp.
References active_threads_, cv_, mutex_, run(), ACE_Thread::spawn(), tsm_, and OpenDDS::DCPS::ConditionVariable< Mutex >::wait().
|
virtual |
bool OpenDDS::DCPS::ThreadPool::contains | ( | ACE_thread_t | id | ) | const |
Check if a specific thread id belongs to this ThreadPool
id | thread id to check |
Definition at line 73 of file ThreadPool.cpp.
References mutex_.
Referenced by OpenDDS::DCPS::DispatchService::shutdown().
|
private |
Definition at line 79 of file ThreadPool.cpp.
References cv_, ACE_Thread::join(), mutex_, OPENDDS_ASSERT, OPENDDS_END_VERSIONED_NAMESPACE_DECL, OPENDDS_VECTOR(), tsm_, and OpenDDS::DCPS::ConditionVariable< Mutex >::wait().
Referenced by ~ThreadPool().
|
private |
|
private |
Referenced by join_all().
|
static |
A static helper function used to redirect to requested thread start point.
Definition at line 52 of file ThreadPool.cpp.
References active_threads_, arg_, cv_, fun_, mutex_, OpenDDS::DCPS::ConditionVariable< Mutex >::notify_all(), OpenDDS::DCPS::ConditionVariable< Mutex >::notify_one(), ACE_Thread::self(), tsm_, and OpenDDS::DCPS::ConditionVariable< Mutex >::wait().
Referenced by ThreadPool().
|
private |
Definition at line 69 of file ThreadPool.h.
Referenced by run(), and ThreadPool().
|
private |
Definition at line 65 of file ThreadPool.h.
Referenced by run().
|
mutableprivate |
Definition at line 67 of file ThreadPool.h.
Referenced by join_all(), run(), and ThreadPool().
|
private |
Definition at line 64 of file ThreadPool.h.
Referenced by run().
|
mutableprivate |
Definition at line 66 of file ThreadPool.h.
Referenced by contains(), join_all(), run(), and ThreadPool().
|
private |
Definition at line 68 of file ThreadPool.h.
Referenced by join_all(), run(), and ThreadPool().