Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / RTCORBA / RT_ORB.h
blob5dde632573c53331f47323d72d472776d65872b6
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
4 * @file RT_ORB.h
6 * @author Marina Spivak <marina@cs.wustl.edu>
7 */
8 //=============================================================================
10 #ifndef TAO_RT_ORB_H
11 #define TAO_RT_ORB_H
12 #include /**/ "ace/pre.h"
14 #include "tao/orbconf.h"
16 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "tao/RTCORBA/RTCORBA_includeC.h"
23 #include "tao/RTCORBA/RT_ORBInitializer.h"
24 #include "tao/LocalObject.h"
25 #include "ace/Hash_Map_Manager_T.h"
27 #if (TAO_HAS_NAMED_RT_MUTEXES == 1)
28 # include "ace/Null_Mutex.h"
29 #endif
31 #if defined(_MSC_VER)
32 #pragma warning(push)
33 #pragma warning(disable:4250)
34 #endif /* _MSC_VER */
36 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
38 // Forward reference for TAO_Named_RT_Mutex_Manager
39 class TAO_RT_Mutex;
40 class TAO_Thread_Pool_Manager;
42 /**
43 * @class TAO_Named_RT_Mutex_Manager
45 * @brief Manages the names of named and unnamed RT Mutexes
47 class TAO_RTCORBA_Export TAO_Named_RT_Mutex_Manager
49 public:
50 /// Constructor.
51 TAO_Named_RT_Mutex_Manager ();
53 /// Destructor.
54 ~TAO_Named_RT_Mutex_Manager ();
56 RTCORBA::Mutex_ptr create_mutex ();
58 void destroy_mutex (RTCORBA::Mutex_ptr the_mutex);
60 RTCORBA::Mutex_ptr create_named_mutex (const char *name,
61 CORBA::Boolean_out created_flag);
63 RTCORBA::Mutex_ptr open_named_mutex (const char * name);
65 private:
66 #if (TAO_HAS_NAMED_RT_MUTEXES == 1)
67 /// Hash map for named RT Mutexes
68 ACE_Hash_Map_Manager_Ex<
69 ACE_CString,
70 RTCORBA::Mutex_var,
71 ACE_Hash<ACE_CString>,
72 ACE_Equal_To<ACE_CString>,
73 ACE_Null_Mutex> map_;
75 TAO_SYNCH_MUTEX lock_;
76 #endif /* TAO_HAS_NAMED_RT_MUTEXES == 1 */
80 /**
81 * @class TAO_RT_ORB
83 * @brief RTCORBA::RTORB implementation
85 * Creates and destroys RT CORBA objects, i.e., policies,
86 * threadpools, mutexes.
88 class TAO_RTCORBA_Export TAO_RT_ORB
89 : public RTCORBA::RTORB,
90 public ::CORBA::LocalObject
92 public:
93 /// Constructor.
94 TAO_RT_ORB (TAO_ORB_Core *orb_core,
95 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan,
96 ACE_Time_Value const &dynamic_thread_time);
98 /**
99 * Create a new mutex. Mutexes returned by this method
100 * are the same as those used internally by the ORB, so that
101 * consistant priority inheritance/piority ceiling semantics
102 * can be guaranteed.
104 virtual RTCORBA::Mutex_ptr create_mutex ();
107 * Destroy a mutex. Currently this is a no-op since RTCORBA::Mutex
108 * instances are destroyed as soon as their reference counts go to
109 * 0.
111 virtual void destroy_mutex (RTCORBA::Mutex_ptr the_mutex);
114 * Create a mutex and assign a name to it. If the
115 * mutex already exists, it is returned and the created_flag
116 * is set to 0.
118 virtual RTCORBA::Mutex_ptr create_named_mutex (const char *name,
119 CORBA::Boolean_out created_flag);
121 /// Retrieve a previously created mutex.
122 virtual RTCORBA::Mutex_ptr open_named_mutex (const char * name);
125 * Create and return a TCPProtocolProperties instance with the specified
126 * parameters.
128 RTCORBA::TCPProtocolProperties_ptr
129 create_tcp_protocol_properties (CORBA::Long send_buffer_size,
130 CORBA::Long recv_buffer_size,
131 CORBA::Boolean keep_alive,
132 CORBA::Boolean dont_route,
133 CORBA::Boolean no_delay,
134 CORBA::Boolean enable_network_priority);
136 RTCORBA::UnixDomainProtocolProperties_ptr
137 create_unix_domain_protocol_properties (CORBA::Long send_buffer_size,
138 CORBA::Long recv_buffer_size);
140 RTCORBA::SharedMemoryProtocolProperties_ptr
141 create_shared_memory_protocol_properties (CORBA::Long send_buffer_size,
142 CORBA::Long recv_buffer_size,
143 CORBA::Boolean keep_alive,
144 CORBA::Boolean dont_route,
145 CORBA::Boolean no_delay,
146 CORBA::Long preallocate_buffer_size,
147 const char *mmap_filename,
148 const char *mmap_lockname);
150 RTCORBA::UserDatagramProtocolProperties_ptr
151 create_user_datagram_protocol_properties (CORBA::Long send_buffer_size,
152 CORBA::Long recv_buffer_size,
153 CORBA::Boolean enable_network_priority);
155 RTCORBA::StreamControlProtocolProperties_ptr
156 create_stream_control_protocol_properties (CORBA::Long send_buffer_size,
157 CORBA::Long recv_buffer_size,
158 CORBA::Boolean keep_alive,
159 CORBA::Boolean dont_route,
160 CORBA::Boolean no_delay,
161 CORBA::Boolean enable_network_priority);
163 /// Create a RTCORBA threadpool to manage a set of threads without lanes.
164 virtual RTCORBA::ThreadpoolId
165 create_threadpool (CORBA::ULong stacksize,
166 CORBA::ULong static_threads,
167 CORBA::ULong dynamic_threads,
168 RTCORBA::Priority default_priority,
169 CORBA::Boolean allow_request_buffering,
170 CORBA::ULong max_buffered_requests,
171 CORBA::ULong max_request_buffer_size);
174 * Create a threadpool and separate it into subsets based on
175 * priorities.
177 virtual RTCORBA::ThreadpoolId
178 create_threadpool_with_lanes (CORBA::ULong stacksize,
179 const RTCORBA::ThreadpoolLanes & lanes,
180 CORBA::Boolean allow_borrowing,
181 CORBA::Boolean allow_request_buffering,
182 CORBA::ULong max_buffered_requests,
183 CORBA::ULong max_request_buffer_size);
185 /// Free the resources associated with the specified threadpool.
186 virtual void destroy_threadpool (RTCORBA::ThreadpoolId threadpool);
188 /// Create a priority model policy for use when configuring a POA.
189 virtual RTCORBA::PriorityModelPolicy_ptr
190 create_priority_model_policy (RTCORBA::PriorityModel priority_model,
191 RTCORBA::Priority server_priority);
193 /// Create a ThreadpoolPolicy instance for POA creation
194 virtual RTCORBA::ThreadpoolPolicy_ptr
195 create_threadpool_policy (RTCORBA::ThreadpoolId threadpool);
198 * Create a PriorityBandedConnectionPolicy instance
199 * for use on either the client or server side
201 virtual RTCORBA::PriorityBandedConnectionPolicy_ptr
202 create_priority_banded_connection_policy (const RTCORBA::PriorityBands &
203 priority_bands);
206 * Create a PrivateConnectionPolicy instance to use on client
207 * to request a private (non-multiplexed) transport connection
208 * to the server.
210 virtual RTCORBA::PrivateConnectionPolicy_ptr
211 create_private_connection_policy ();
214 * Create a ServerProtocolPolicy instance to select and configure
215 * communication protocols on the server side.
217 virtual RTCORBA::ServerProtocolPolicy_ptr
218 create_server_protocol_policy (const RTCORBA::ProtocolList & protocols);
221 * Create a ClientProtocolPolicy instance to select and configure
222 * communication protocols on the client side.
224 virtual RTCORBA::ClientProtocolPolicy_ptr
225 create_client_protocol_policy (const RTCORBA::ProtocolList & protocols);
227 /// Reference to our creating ORB Core.
228 TAO_ORB_Core *orb_core () const;
230 /// Get the Thread Pool Manager.
231 TAO_Thread_Pool_Manager &tp_manager () const;
234 * This method changes the scheduling policy of the calling thread
235 * to match the scheduling policy specified in the svc.conf file.
236 * The priority of the calling thread will be set to the minimum
237 * priority supported by that scheduling policy.
239 * This method make sense on those platform (e.g., Linux) where
240 * PTHREAD_SCOPE_SYSTEM is the only scheduling scope supported. On
241 * other platforms, this method is a no-op since the only way to get
242 * the real-time threading behavior is to setup the
243 * PTHREAD_SCOPE_SYSTEM scheduling scope when a thread is being
244 * created. On such platforms, one can set the correct scheduling
245 * scope and policy when creating the thread, thus not needing to
246 * use this method.
248 static int modify_thread_scheduling_policy (CORBA::ORB_ptr orb);
250 protected:
251 /// Protected destructor to enforce proper memory management of this
252 /// reference counted object.
253 virtual ~TAO_RT_ORB ();
255 protected:
256 /// Reference to our creating ORB Core.
257 TAO_ORB_Core * const orb_core_;
259 /// mutex_mgr_ manages the names associated with named mutexes.
260 TAO_Named_RT_Mutex_Manager mutex_mgr_;
262 /// Thread Pool Manager
263 TAO_Thread_Pool_Manager *tp_manager_;
265 /// Dynamic thread lifespan policy
266 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan_;
268 /// Dynamic thread run time
269 ACE_Time_Value const dynamic_thread_time_;
272 TAO_END_VERSIONED_NAMESPACE_DECL
274 #if defined(_MSC_VER)
275 #pragma warning(pop)
276 #endif /* _MSC_VER */
278 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */
280 #include /**/ "ace/post.h"
281 #endif /* TAO_RT_ORB_H */