00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file CEC_MT_Dispatching.h 00006 * 00007 * CEC_MT_Dispatching.h,v 1.16 2006/03/14 06:14:24 jtc Exp 00008 * 00009 * @author Carlos O'Ryan (coryan@cs.wustl.edu) 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef TAO_CEC_MT_DISPATCHING_H 00015 #define TAO_CEC_MT_DISPATCHING_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #include "orbsvcs/CosEvent/CEC_Dispatching.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 # pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 #include "orbsvcs/CosEvent/CEC_Dispatching_Task.h" 00026 00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00028 00029 class TAO_CEC_EventChannel; 00030 00031 /** 00032 * @class TAO_CEC_MT_Dispatching 00033 * 00034 * @brief Dispatching strategy that minimizes mt inversion. 00035 * 00036 * This strategy uses a single queue, serviced by one or more 00037 * threads. It's main purpose is to decouple the suppliers from 00038 * the client execution time, specially in the collocated case. 00039 */ 00040 class TAO_Event_Serv_Export TAO_CEC_MT_Dispatching : public TAO_CEC_Dispatching 00041 { 00042 public: 00043 /// Constructor 00044 /// It will create <nthreads> servicing threads... 00045 TAO_CEC_MT_Dispatching (int nthreads, 00046 int thread_creation_flags, 00047 int thread_priority, 00048 int force_activate); 00049 00050 // = The EC_Dispatching methods. 00051 virtual void activate (void); 00052 virtual void shutdown (void); 00053 virtual void push (TAO_CEC_ProxyPushSupplier* proxy, 00054 const CORBA::Any & event 00055 ACE_ENV_ARG_DECL); 00056 virtual void push_nocopy (TAO_CEC_ProxyPushSupplier* proxy, 00057 CORBA::Any& event 00058 ACE_ENV_ARG_DECL); 00059 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL) 00060 virtual void invoke (TAO_CEC_ProxyPushSupplier *proxy, 00061 const TAO_CEC_TypedEvent & typed_event 00062 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00063 virtual void invoke_nocopy (TAO_CEC_ProxyPushSupplier *proxy, 00064 TAO_CEC_TypedEvent & typed_event 00065 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00066 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ 00067 00068 private: 00069 /// Use our own thread manager. 00070 ACE_Thread_Manager thread_manager_; 00071 00072 /// The number of active tasks 00073 int nthreads_; 00074 00075 /// The flags (THR_BOUND, THR_NEW_LWP, etc.) used to create the 00076 /// dispatching threads. 00077 int thread_creation_flags_; 00078 00079 /// The priority of the dispatching threads. 00080 int thread_priority_; 00081 00082 /// If activation at the requested priority fails then we fallback on 00083 /// the defaults for thread activation. 00084 int force_activate_; 00085 00086 /// The dispatching task 00087 TAO_CEC_Dispatching_Task task_; 00088 00089 /// Synchronize access to internal data 00090 TAO_SYNCH_MUTEX lock_; 00091 00092 /// Are the threads running? 00093 int active_; 00094 }; 00095 00096 TAO_END_VERSIONED_NAMESPACE_DECL 00097 00098 #include /**/ "ace/post.h" 00099 00100 #endif /* TAO_CEC_MT_DISPATCHING_H */