#include <CEC_MT_Dispatching.h>
Inheritance diagram for TAO_CEC_MT_Dispatching:
Public Member Functions | |
TAO_CEC_MT_Dispatching (int nthreads, int thread_creation_flags, int thread_priority, int force_activate) | |
virtual void | activate (void) |
virtual void | shutdown (void) |
virtual void | push (TAO_CEC_ProxyPushSupplier *proxy, const CORBA::Any &event) |
The consumer represented by <proxy> should receive <event>. | |
virtual void | push_nocopy (TAO_CEC_ProxyPushSupplier *proxy, CORBA::Any &event) |
Private Attributes | |
ACE_Thread_Manager | thread_manager_ |
Use our own thread manager. | |
int | nthreads_ |
The number of active tasks. | |
int | thread_creation_flags_ |
int | thread_priority_ |
The priority of the dispatching threads. | |
int | force_activate_ |
TAO_CEC_Dispatching_Task | task_ |
The dispatching task. | |
TAO_SYNCH_MUTEX | lock_ |
Synchronize access to internal data. | |
int | active_ |
Are the threads running? |
This strategy uses a single queue, serviced by one or more threads. It's main purpose is to decouple the suppliers from the client execution time, specially in the collocated case.
Definition at line 40 of file CEC_MT_Dispatching.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_CEC_MT_Dispatching::TAO_CEC_MT_Dispatching | ( | int | nthreads, | |
int | thread_creation_flags, | |||
int | thread_priority, | |||
int | force_activate | |||
) |
Constructor It will create <nthreads> servicing threads...
Definition at line 12 of file CEC_MT_Dispatching.cpp.
00016 : nthreads_ (nthreads), 00017 thread_creation_flags_ (thread_creation_flags), 00018 thread_priority_ (thread_priority), 00019 force_activate_ (force_activate), 00020 task_ (&this->thread_manager_), 00021 active_ (0) 00022 { 00023 }
void TAO_CEC_MT_Dispatching::activate | ( | void | ) | [virtual] |
Initialize all the data structures, activate any internal threads, etc.
Implements TAO_CEC_Dispatching.
Definition at line 26 of file CEC_MT_Dispatching.cpp.
References ACE_ERROR, ACE_GUARD, active_, LM_ERROR, TAO_SYNCH_MUTEX, and THR_BOUND.
Referenced by push_nocopy().
00027 { 00028 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); 00029 00030 if (this->active_ != 0) 00031 return; 00032 00033 this->active_ = 1; 00034 00035 if (this->task_.activate (this->thread_creation_flags_, 00036 this->nthreads_, 00037 1, 00038 this->thread_priority_) == -1) 00039 { 00040 if (this->force_activate_ != 0) 00041 { 00042 if (this->task_.activate (THR_BOUND, this->nthreads_) == -1) 00043 ACE_ERROR ((LM_ERROR, 00044 "EC (%P|%t) cannot activate dispatching queue")); 00045 } 00046 } 00047 }
void TAO_CEC_MT_Dispatching::push | ( | TAO_CEC_ProxyPushSupplier * | proxy, | |
const CORBA::Any & | event | |||
) | [virtual] |
The consumer represented by <proxy> should receive <event>.
Implements TAO_CEC_Dispatching.
Definition at line 65 of file CEC_MT_Dispatching.cpp.
References push_nocopy().
00067 { 00068 CORBA::Any event_copy = event; 00069 this->push_nocopy (proxy, event_copy); 00070 }
void TAO_CEC_MT_Dispatching::push_nocopy | ( | TAO_CEC_ProxyPushSupplier * | proxy, | |
CORBA::Any & | event | |||
) | [virtual] |
Implements TAO_CEC_Dispatching.
Definition at line 73 of file CEC_MT_Dispatching.cpp.
References activate(), TAO_CEC_Dispatching_Task::push(), and task_.
Referenced by push().
00075 { 00076 // Double checked locking.... 00077 if (this->active_ == 0) 00078 this->activate (); 00079 00080 this->task_.push (proxy, event); 00081 }
void TAO_CEC_MT_Dispatching::shutdown | ( | void | ) | [virtual] |
Deactivate any internal threads and cleanup internal data structures, it should only return once the threads have finished their jobs.
Implements TAO_CEC_Dispatching.
Definition at line 50 of file CEC_MT_Dispatching.cpp.
References ACE_GUARD, nthreads_, TAO_SYNCH_MUTEX, thread_manager_, and ACE_Thread_Manager::wait().
00051 { 00052 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); 00053 00054 if (this->active_ == 0) 00055 return; 00056 00057 for (int i = 0; i < this->nthreads_; ++i) 00058 { 00059 this->task_.putq (new TAO_CEC_Shutdown_Task_Command); 00060 } 00061 this->thread_manager_.wait (); 00062 }
int TAO_CEC_MT_Dispatching::active_ [private] |
Are the threads running?
Definition at line 89 of file CEC_MT_Dispatching.h.
Referenced by activate().
int TAO_CEC_MT_Dispatching::force_activate_ [private] |
If activation at the requested priority fails then we fallback on the defaults for thread activation.
Definition at line 80 of file CEC_MT_Dispatching.h.
TAO_SYNCH_MUTEX TAO_CEC_MT_Dispatching::lock_ [private] |
int TAO_CEC_MT_Dispatching::nthreads_ [private] |
The number of active tasks.
Definition at line 69 of file CEC_MT_Dispatching.h.
Referenced by shutdown().
The dispatching task.
Definition at line 83 of file CEC_MT_Dispatching.h.
Referenced by push_nocopy().
int TAO_CEC_MT_Dispatching::thread_creation_flags_ [private] |
The flags (THR_BOUND, THR_NEW_LWP, etc.) used to create the dispatching threads.
Definition at line 73 of file CEC_MT_Dispatching.h.
Use our own thread manager.
Definition at line 66 of file CEC_MT_Dispatching.h.
Referenced by shutdown().
int TAO_CEC_MT_Dispatching::thread_priority_ [private] |