RT_ORB.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 //=============================================================================
00003 /**
00004  *  @file   RT_ORB.h
00005  *
00006  *  $Id: RT_ORB.h 81429 2008-04-24 18:49:54Z johnnyw $
00007  *
00008  *  @author Marina Spivak <marina@cs.wustl.edu>
00009  */
00010 //=============================================================================
00011 
00012 #ifndef TAO_RT_ORB_H
00013 #define TAO_RT_ORB_H
00014 #include /**/ "ace/pre.h"
00015 
00016 #include "tao/orbconf.h"
00017 
00018 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "tao/RTCORBA/RTCORBA_includeC.h"
00025 #include "tao/RTCORBA/RT_ORBInitializer.h"
00026 #include "tao/LocalObject.h"
00027 #include "ace/Hash_Map_Manager_T.h"
00028 
00029 #if (TAO_HAS_NAMED_RT_MUTEXES == 1)
00030 # include "ace/Null_Mutex.h"
00031 #endif
00032 
00033 #if defined(_MSC_VER)
00034 #pragma warning(push)
00035 #pragma warning(disable:4250)
00036 #endif /* _MSC_VER */
00037 
00038 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00039 
00040 // Forward reference for TAO_Named_RT_Mutex_Manager
00041 class TAO_RT_Mutex;
00042 class TAO_Thread_Pool_Manager;
00043 
00044 /**
00045  * @class TAO_Named_RT_Mutex_Manager
00046  *
00047  * @brief Manages the names of named and unnamed RT Mutexes
00048  *
00049  */
00050 class TAO_RTCORBA_Export TAO_Named_RT_Mutex_Manager
00051 {
00052 
00053 public:
00054   /// Constructor.
00055   TAO_Named_RT_Mutex_Manager (void);
00056 
00057   /// Destructor.
00058   ~TAO_Named_RT_Mutex_Manager (void);
00059 
00060   RTCORBA::Mutex_ptr create_mutex (void);
00061 
00062   void destroy_mutex (RTCORBA::Mutex_ptr the_mutex);
00063 
00064   RTCORBA::Mutex_ptr create_named_mutex (const char *name,
00065                                          CORBA::Boolean_out created_flag);
00066 
00067   RTCORBA::Mutex_ptr open_named_mutex (const char * name);
00068 
00069 private:
00070 
00071 #if (TAO_HAS_NAMED_RT_MUTEXES == 1)
00072   /// Hash map for named RT Mutexes
00073   ACE_Hash_Map_Manager_Ex<
00074     ACE_CString,
00075     RTCORBA::Mutex_var,
00076     ACE_Hash<ACE_CString>,
00077     ACE_Equal_To<ACE_CString>,
00078     ACE_Null_Mutex> map_;
00079 
00080   TAO_SYNCH_MUTEX lock_;
00081 #endif /* TAO_HAS_NAMED_RT_MUTEXES == 1 */
00082 };
00083 
00084 
00085 /**
00086  * @class TAO_RT_ORB
00087  *
00088  * @brief RTCORBA::RTORB implementation
00089  *
00090  * Creates and destroys RT CORBA objects, i.e., policies,
00091  * threadpools, mutexes.
00092  */
00093 class TAO_RTCORBA_Export TAO_RT_ORB
00094   : public RTCORBA::RTORB,
00095     public ::CORBA::LocalObject
00096 {
00097 public:
00098 
00099   /// Constructor.
00100   TAO_RT_ORB (TAO_ORB_Core *orb_core,
00101               TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan,
00102               ACE_Time_Value const &dynamic_thread_time);
00103 
00104   /**
00105    * Create a new mutex.  Mutexes returned by this method
00106    * are the same as those used internally by the ORB, so that
00107    * consistant priority inheritance/piority ceiling semantics
00108    * can be guaranteed.
00109    */
00110   virtual RTCORBA::Mutex_ptr create_mutex (void);
00111 
00112   /**
00113    * Destroy a mutex.  Currently this is a no-op since RTCORBA::Mutex
00114    * instances are destroyed as soon as their reference counts go to
00115    * 0.
00116    */
00117   virtual void destroy_mutex (RTCORBA::Mutex_ptr the_mutex);
00118 
00119   /**
00120    * Create a mutex and assign a name to it.  If the
00121    * mutex already exists, it is returned and the created_flag
00122    * is set to 0.
00123    */
00124   virtual RTCORBA::Mutex_ptr create_named_mutex (const char *name,
00125                                                  CORBA::Boolean_out created_flag);
00126 
00127   /// Retrieve a previously created mutex.
00128   virtual RTCORBA::Mutex_ptr open_named_mutex (const char * name);
00129 
00130   /**
00131    * Create and return a TCPProtocolProperties instance with the specified
00132    * parameters.
00133    */
00134   RTCORBA::TCPProtocolProperties_ptr
00135   create_tcp_protocol_properties (CORBA::Long send_buffer_size,
00136                                   CORBA::Long recv_buffer_size,
00137                                   CORBA::Boolean keep_alive,
00138                                   CORBA::Boolean dont_route,
00139                                   CORBA::Boolean no_delay,
00140                                   CORBA::Boolean enable_network_priority);
00141 
00142   RTCORBA::UnixDomainProtocolProperties_ptr
00143   create_unix_domain_protocol_properties (CORBA::Long send_buffer_size,
00144                                           CORBA::Long recv_buffer_size);
00145 
00146   RTCORBA::SharedMemoryProtocolProperties_ptr
00147   create_shared_memory_protocol_properties (CORBA::Long send_buffer_size,
00148                                             CORBA::Long recv_buffer_size,
00149                                             CORBA::Boolean keep_alive,
00150                                             CORBA::Boolean dont_route,
00151                                             CORBA::Boolean no_delay,
00152                                             CORBA::Long preallocate_buffer_size,
00153                                             const char *mmap_filename,
00154                                             const char *mmap_lockname);
00155 
00156   RTCORBA::UserDatagramProtocolProperties_ptr
00157   create_user_datagram_protocol_properties (CORBA::Long send_buffer_size,
00158                                             CORBA::Long recv_buffer_size,
00159                                             CORBA::Boolean enable_network_priority);
00160 
00161   RTCORBA::StreamControlProtocolProperties_ptr
00162   create_stream_control_protocol_properties (CORBA::Long send_buffer_size,
00163                                              CORBA::Long recv_buffer_size,
00164                                              CORBA::Boolean keep_alive,
00165                                              CORBA::Boolean dont_route,
00166                                              CORBA::Boolean no_delay,
00167                                              CORBA::Boolean enable_network_priority);
00168 
00169   /// Create a RTCORBA threadpool to manage a set of threads without lanes.
00170   virtual RTCORBA::ThreadpoolId
00171   create_threadpool (CORBA::ULong stacksize,
00172                      CORBA::ULong static_threads,
00173                      CORBA::ULong dynamic_threads,
00174                      RTCORBA::Priority default_priority,
00175                      CORBA::Boolean allow_request_buffering,
00176                      CORBA::ULong max_buffered_requests,
00177                      CORBA::ULong max_request_buffer_size);
00178 
00179   /**
00180    * Create a threadpool and separate it into subsets based on
00181    * priorities.
00182    */
00183   virtual RTCORBA::ThreadpoolId
00184   create_threadpool_with_lanes (CORBA::ULong stacksize,
00185                                 const RTCORBA::ThreadpoolLanes & lanes,
00186                                 CORBA::Boolean allow_borrowing,
00187                                 CORBA::Boolean allow_request_buffering,
00188                                 CORBA::ULong max_buffered_requests,
00189                                 CORBA::ULong max_request_buffer_size);
00190 
00191   /// Free the resources associated with the specified threadpool.
00192   virtual void destroy_threadpool (RTCORBA::ThreadpoolId threadpool);
00193 
00194   /// Create a priority model policy for use when configuring a POA.
00195   virtual RTCORBA::PriorityModelPolicy_ptr
00196   create_priority_model_policy (RTCORBA::PriorityModel priority_model,
00197                                 RTCORBA::Priority server_priority);
00198 
00199   /// Create a ThreadpoolPolicy instance for POA creation
00200   virtual RTCORBA::ThreadpoolPolicy_ptr
00201   create_threadpool_policy (RTCORBA::ThreadpoolId threadpool);
00202 
00203   /**
00204    * Create a PriorityBandedConnectionPolicy instance
00205    * for use on either the client or server side
00206    */
00207   virtual RTCORBA::PriorityBandedConnectionPolicy_ptr
00208   create_priority_banded_connection_policy (const RTCORBA::PriorityBands &
00209                                             priority_bands);
00210 
00211   /**
00212    * Create a PrivateConnectionPolicy instance to use on client
00213    * to request a private (non-multiplexed) transport connection
00214    * to the server.
00215    */
00216   virtual RTCORBA::PrivateConnectionPolicy_ptr
00217   create_private_connection_policy (void);
00218 
00219   /**
00220    * Create a ServerProtocolPolicy instance to select and configure
00221    * communication protocols on the server side.
00222    */
00223   virtual RTCORBA::ServerProtocolPolicy_ptr
00224   create_server_protocol_policy (const RTCORBA::ProtocolList & protocols);
00225 
00226   /**
00227    * Create a ClientProtocolPolicy instance to select and configure
00228    * communication protocols on the client side.
00229    */
00230   virtual RTCORBA::ClientProtocolPolicy_ptr
00231   create_client_protocol_policy (const RTCORBA::ProtocolList & protocols);
00232 
00233   /// Reference to our creating ORB Core.
00234   TAO_ORB_Core *orb_core (void) const;
00235 
00236   /// Get the Thread Pool Manager.
00237   TAO_Thread_Pool_Manager &tp_manager (void) const;
00238 
00239   /**
00240    * This method changes the scheduling policy of the calling thread
00241    * to match the scheduling policy specified in the svc.conf file.
00242    * The priority of the calling thread will be set to the minimum
00243    * priority supported by that scheduling policy.
00244    *
00245    * This method make sense on those platform (e.g., Linux) where
00246    * PTHREAD_SCOPE_SYSTEM is the only scheduling scope supported.  On
00247    * other platforms, this method is a no-op since the only way to get
00248    * the real-time threading behavior is to setup the
00249    * PTHREAD_SCOPE_SYSTEM scheduling scope when a thread is being
00250    * created.  On such platforms, one can set the correct scheduling
00251    * scope and policy when creating the thread, thus not needing to
00252    * use this method.
00253    */
00254   static int modify_thread_scheduling_policy (CORBA::ORB_ptr orb);
00255 
00256 protected:
00257 
00258   /// Protected destructor to enforce proper memory management of this
00259   /// reference counted object.
00260   virtual ~TAO_RT_ORB (void);
00261 
00262 protected:
00263 
00264   /// Reference to our creating ORB Core.
00265   TAO_ORB_Core * const orb_core_;
00266 
00267   /// mutex_mgr_ manages the names associated with named mutexes.
00268   TAO_Named_RT_Mutex_Manager mutex_mgr_;
00269 
00270   /// Thread Pool Manager
00271   TAO_Thread_Pool_Manager *tp_manager_;
00272 
00273   /// Dynamic thread lifespan policy
00274   TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan_;
00275 
00276   /// Dynamic thread run time
00277   ACE_Time_Value const dynamic_thread_time_;
00278 };
00279 
00280 TAO_END_VERSIONED_NAMESPACE_DECL
00281 
00282 #if defined(_MSC_VER)
00283 #pragma warning(pop)
00284 #endif /* _MSC_VER */
00285 
00286 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */
00287 
00288 #include /**/ "ace/post.h"
00289 #endif /* TAO_RT_ORB_H */

Generated on Tue Feb 2 17:42:49 2010 for TAO_RTCORBA by  doxygen 1.4.7