RT_ORB.h

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

Generated on Thu Nov 9 12:58:01 2006 for TAO_RTCORBA by doxygen 1.3.6