summaryrefslogtreecommitdiff
path: root/TAO/tao/RT_ORB.h
blob: 632f5fe2d8338510110bdb2aced56c11816b20cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* -*- C++ -*- */
//=============================================================================
/**
 *  @file   RT_ORB.h
 *
 *  $Id$
 *
 *  @author Marina Spivak <marina@cs.wustl.edu>
 */
//=============================================================================

#ifndef TAO_RT_ORB_H
#define TAO_RT_ORB_H
#include "ace/pre.h"

#include "tao/orbconf.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#if (TAO_HAS_RT_CORBA == 1)

#include "tao/RTCORBAC.h"
#include "tao/LocalObject.h"
#include "tao/Thread_Pool.h"
#include "ace/Hash_Map_Manager_T.h"

#if defined(_MSC_VER)
#if (_MSC_VER >= 1200)
#pragma warning(push)
#endif /* _MSC_VER >= 1200 */
#pragma warning(disable:4250)
#endif /* _MSC_VER */

// Forward reference for TAO_Named_RT_Mutex_Manager
class TAO_RT_Mutex;

/**
 * @class TAO_Named_RT_Mutex_Manager
 *
 * @brief Manages the names of named and unnamed RT Mutexes
 *
 */

class TAO_Export TAO_Named_RT_Mutex_Manager
{

public:
  /// Constructor.
  TAO_Named_RT_Mutex_Manager (void);

  /// Destructor.
  ~TAO_Named_RT_Mutex_Manager (void);

  RTCORBA::Mutex_ptr create_mutex (CORBA::Environment
                                   &ACE_TRY_ENV =
                                   TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  void destroy_mutex (RTCORBA::Mutex_ptr the_mutex,
                      CORBA::Environment &ACE_TRY_ENV =
                      TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  RTCORBA::Mutex_ptr create_named_mutex (const char *name,
                                         CORBA::Boolean_out created_flag,
                                         CORBA::Environment
                                         &ACE_TRY_ENV =
                                         TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  RTCORBA::Mutex_ptr open_named_mutex (const char * name,
                                       CORBA::Environment &ACE_TRY_ENV =
                                       TAO_default_environment () )
    ACE_THROW_SPEC ((CORBA::SystemException,
                     RTCORBA::RTORB::MutexNotFound
                     ));

private:

#if (TAO_HAS_NAMED_RT_MUTEXES == 1)
  /// Hash map for named RT Mutexes
  ACE_Hash_Map_Manager_Ex<
    ACE_CString,
    RTCORBA::Mutex_var,
    ACE_Hash<ACE_CString>,
    ACE_Equal_To<ACE_CString>,
    ACE_Null_Mutex> map_;

  TAO_SYNCH_MUTEX lock_;
#endif /* TAO_HAS_NAMED_RT_MUTEXES == 1 */
};


/**
 * @class TAO_RT_ORB
 *
 * @brief RTCORBA::RTORB implementation
 *
 * Creates and destroys RT CORBA objects, i.e., policies,
 * threadpools, mutexes.
 */
class TAO_Export TAO_RT_ORB
  : public RTCORBA::RTORB,
    public TAO_Local_RefCounted_Object
{
public:
  /// Constructor.
  TAO_RT_ORB (CORBA::ORB_ptr orb);

  /**
   * Create a new mutex.  Mutexes returned by this method
   * are the same as those used internally by the ORB, so that
   * consistant priority inheritance/piority ceiling semantics
   * can be guaranteed.
   */
  virtual RTCORBA::Mutex_ptr create_mutex (CORBA::Environment
                                           &ACE_TRY_ENV =
                                           TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /**
   * Destroy a mutex.  Currently this is a no-op since RTCORBA::Mutex
   * instances are destroyed as soon as their reference counts go to
   * 0.
   */
  virtual void destroy_mutex (RTCORBA::Mutex_ptr the_mutex,
                              CORBA::Environment &ACE_TRY_ENV =
                              TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /**
   * Create a mutex and assign a name to it.  If the
   * mutex already exists, it is returned and the created_flag
   * is set to 0.
   */
  virtual RTCORBA::Mutex_ptr create_named_mutex (const char *name,
                                                 CORBA::Boolean_out created_flag,
                                                 CORBA::Environment
                                                 &ACE_TRY_ENV =
                                                 TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /// Retrieve a previously created mutex.
  virtual RTCORBA::Mutex_ptr open_named_mutex (const char * name,
                                                CORBA::Environment &ACE_TRY_ENV =
                                                TAO_default_environment () )
     ACE_THROW_SPEC ((CORBA::SystemException,
                      RTCORBA::RTORB::MutexNotFound
                      ));

  /**
   * Create and return a TCPProtocolProperties instance with the specified
   * parameters.
   */
  virtual RTCORBA::TCPProtocolProperties_ptr
  create_tcp_protocol_properties (
                                  CORBA::Long send_buffer_size,
                                  CORBA::Long recv_buffer_size,
                                  CORBA::Boolean keep_alive,
                                  CORBA::Boolean dont_route,
                                  CORBA::Boolean no_delay,
                                  CORBA::Environment
                                  &ACE_TRY_ENV = TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException ));

  /// Create a RTCORBA threadpool to manage a set of threads without lanes.
  virtual RTCORBA::ThreadpoolId
  create_threadpool (CORBA::ULong stacksize,
                     CORBA::ULong static_threads,
                     CORBA::ULong dynamic_threads,
                     RTCORBA::Priority default_priority,
                     CORBA::Boolean allow_request_buffering,
                     CORBA::ULong max_buffered_requests,
                     CORBA::ULong max_request_buffer_size,
                     CORBA::Environment
                     &ACE_TRY_ENV = TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /**
   * Create a threadpool and separate it into subsets based on
   * priorities.
   */
  virtual RTCORBA::ThreadpoolId
  create_threadpool_with_lanes (CORBA::ULong stacksize,
                                const RTCORBA::ThreadpoolLanes & lanes,
                                CORBA::Boolean allow_borrowing,
                                CORBA::Boolean allow_request_buffering,
                                CORBA::ULong max_buffered_requests,
                                CORBA::ULong max_request_buffer_size,
                                CORBA::Environment &ACE_TRY_ENV =
                                TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /// Free the resources associated with the specified threadpool.
  virtual void destroy_threadpool (RTCORBA::ThreadpoolId threadpool,
                                   CORBA::Environment &ACE_TRY_ENV =
                                   TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     RTCORBA::RTORB::InvalidThreadpool));

  /// Create a priority model policy for use when configuring a POA.
  virtual RTCORBA::PriorityModelPolicy_ptr
  create_priority_model_policy (
                                RTCORBA::PriorityModel priority_model,
                                RTCORBA::Priority server_priority,
                                CORBA::Environment &ACE_TRY_ENV =
                                TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /// Create a ThreadpoolPolicy instance for POA creation
  virtual RTCORBA::ThreadpoolPolicy_ptr
  create_threadpool_policy (RTCORBA::ThreadpoolId threadpool,
                            CORBA::Environment &ACE_TRY_ENV =
                            TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /**
   * Create a PriorityBandedConnectionPolicy instance
   * for use on either the client or server side
   */
  virtual RTCORBA::PriorityBandedConnectionPolicy_ptr
  create_priority_banded_connection_policy (const RTCORBA::PriorityBands &
                                            priority_bands,
                                            CORBA::Environment &ACE_TRY_ENV =
                                            TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /**
   * Create a PrivateConnectionPolicy instance to use on client
   * to request a private (non-multiplexed) transport connection
   * to the server.
   */
  virtual RTCORBA::PrivateConnectionPolicy_ptr
  create_private_connection_policy (CORBA::Environment &ACE_TRY_ENV =
                                    TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /**
   * Create a ServerProtocolPolicy instance to select and configure
   * communication protocols on the server side.
   */
  virtual RTCORBA::ServerProtocolPolicy_ptr
  create_server_protocol_policy (const RTCORBA::ProtocolList & protocols,
                                 CORBA::Environment &ACE_TRY_ENV =
                                 TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /**
   * Create a ClientProtocolPolicy instance to select and configure
   * communication protocols on the client side.
   */
  virtual RTCORBA::ClientProtocolPolicy_ptr
  create_client_protocol_policy (const RTCORBA::ProtocolList & protocols,
                                 CORBA::Environment &ACE_TRY_ENV =
                                 TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

protected:
  /// Protected destructor to enforce proper memory management of this
  /// reference counted object.
  virtual ~TAO_RT_ORB (void);

  /// Reference to our creating ORB.
  CORBA::ORB_var orb_;

  /// mutex_mgr_ manages the names associated with named mutexes.
  TAO_Named_RT_Mutex_Manager mutex_mgr_;

  /// Thread Pool Manager.
  TAO_Thread_Pool_Manager tp_manager_;
};

#if defined (__ACE_INLINE__)
#include "tao/RT_ORB.i"
#endif /* __ACE_INLINE__ */

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma warning(pop)
#endif /* _MSC_VER */

#endif /* TAO_HAS_RT_CORBA == 1 */

#include "ace/post.h"
#endif /* TAO_RT_ORB_H */