~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to TAO/orbsvcs/orbsvcs/Event/EC_Event_Channel_Base.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// EC_Event_Channel_Base.cpp,v 1.4 2003/08/13 09:03:45 jwillemsen Exp
2
 
 
3
 
#include "EC_Event_Channel_Base.h"
4
 
#include "EC_Dispatching.h"
5
 
#include "EC_ConsumerAdmin.h"
6
 
#include "EC_SupplierAdmin.h"
7
 
#include "EC_Timeout_Generator.h"
8
 
#include "EC_ObserverStrategy.h"
9
 
#include "EC_ConsumerControl.h"
10
 
#include "EC_SupplierControl.h"
11
 
#include "ace/Dynamic_Service.h"
12
 
 
13
 
#if ! defined (__ACE_INLINE__)
14
 
#include "EC_Event_Channel_Base.i"
15
 
#endif /* __ACE_INLINE__ */
16
 
 
17
 
ACE_RCSID(Event, EC_Event_Channel_Base, "EC_Event_Channel_Base.cpp,v 1.4 2003/08/13 09:03:45 jwillemsen Exp")
18
 
 
19
 
TAO_EC_Event_Channel_Base::
20
 
TAO_EC_Event_Channel_Base (const TAO_EC_Event_Channel_Attributes& attr,
21
 
                           TAO_EC_Factory* factory,
22
 
                           int own_factory)
23
 
  : supplier_poa_ (PortableServer::POA::_duplicate (attr.supplier_poa)),
24
 
    consumer_poa_ (PortableServer::POA::_duplicate (attr.consumer_poa)),
25
 
    factory_ (factory),
26
 
    own_factory_ (own_factory),
27
 
    dispatching_ (0),
28
 
    filter_builder_ (0),
29
 
    supplier_filter_builder_ (0),
30
 
    consumer_admin_ (0),
31
 
    supplier_admin_ (0),
32
 
    timeout_generator_ (0),
33
 
    observer_strategy_ (0),
34
 
    scheduling_strategy_(0),
35
 
    consumer_reconnect_ (attr.consumer_reconnect),
36
 
    supplier_reconnect_ (attr.supplier_reconnect),
37
 
    disconnect_callbacks_ (attr.disconnect_callbacks),
38
 
    consumer_control_ (0),
39
 
    supplier_control_ (0),
40
 
    status_ (EC_S_IDLE)
41
 
{
42
 
  this->scheduler_ =
43
 
    CORBA::Object::_duplicate (attr.scheduler);
44
 
}
45
 
 
46
 
TAO_EC_Event_Channel_Base::~TAO_EC_Event_Channel_Base (void)
47
 
{
48
 
  // Destroy Strategies in the reverse order of creation, they
49
 
  // refere to each other during destruction and thus need to be
50
 
  // cleaned up properly.
51
 
  this->factory_->destroy_supplier_control (this->supplier_control_);
52
 
  this->supplier_control_ = 0;
53
 
  this->factory_->destroy_consumer_control (this->consumer_control_);
54
 
  this->consumer_control_ = 0;
55
 
 
56
 
  this->factory_->destroy_scheduling_strategy (this->scheduling_strategy_);
57
 
  this->scheduling_strategy_ = 0;
58
 
 
59
 
  this->factory_->destroy_observer_strategy (this->observer_strategy_);
60
 
  this->observer_strategy_ = 0;
61
 
 
62
 
  this->factory_->destroy_timeout_generator (this->timeout_generator_);
63
 
  this->timeout_generator_ = 0;
64
 
 
65
 
  this->factory_->destroy_supplier_admin (this->supplier_admin_);
66
 
  this->supplier_admin_ = 0;
67
 
  this->factory_->destroy_consumer_admin (this->consumer_admin_);
68
 
  this->consumer_admin_ = 0;
69
 
 
70
 
  this->factory_->destroy_supplier_filter_builder (this->supplier_filter_builder_);
71
 
  this->supplier_filter_builder_ = 0;
72
 
 
73
 
  this->factory_->destroy_filter_builder (this->filter_builder_);
74
 
  this->filter_builder_ = 0;
75
 
 
76
 
  this->factory_->destroy_dispatching (this->dispatching_);
77
 
  this->dispatching_ = 0;
78
 
 
79
 
  this->factory (0, 0);
80
 
}
81
 
 
82
 
void
83
 
TAO_EC_Event_Channel_Base::create_strategies (void)
84
 
{
85
 
  this->dispatching_ =
86
 
    this->factory_->create_dispatching (this);
87
 
  this->filter_builder_ =
88
 
    this->factory_->create_filter_builder (this);
89
 
  this->supplier_filter_builder_ =
90
 
    this->factory_->create_supplier_filter_builder (this);
91
 
  this->consumer_admin_ =
92
 
    this->factory_->create_consumer_admin (this);
93
 
  this->supplier_admin_ =
94
 
    this->factory_->create_supplier_admin (this);
95
 
  this->timeout_generator_ =
96
 
    this->factory_->create_timeout_generator (this);
97
 
  this->observer_strategy_ =
98
 
    this->factory_->create_observer_strategy (this);
99
 
 
100
 
  this->scheduling_strategy_ =
101
 
    this->factory_->create_scheduling_strategy (this);
102
 
 
103
 
  this->consumer_control_ =
104
 
    this->factory_->create_consumer_control (this);
105
 
  this->supplier_control_ =
106
 
    this->factory_->create_supplier_control (this);
107
 
}
108
 
 
109
 
void
110
 
TAO_EC_Event_Channel_Base::activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
111
 
{
112
 
  {
113
 
    // First check if the EC is idle, if it is not then we need to
114
 
    // return right away...
115
 
    ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
116
 
    if (this->status_ != EC_S_IDLE)
117
 
      return;
118
 
    this->status_ = EC_S_ACTIVATING;
119
 
  }
120
 
  this->dispatching_->activate ();
121
 
  this->timeout_generator_->activate ();
122
 
  this->consumer_control_->activate ();
123
 
  this->supplier_control_->activate ();
124
 
  {
125
 
    // Only when all the operations complete successfully we can mark
126
 
    // the EC as active...
127
 
    ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
128
 
    ACE_ASSERT (this->status_ == EC_S_ACTIVATING);
129
 
    this->status_ = EC_S_ACTIVE;
130
 
  }
131
 
}
132
 
 
133
 
void
134
 
TAO_EC_Event_Channel_Base::shutdown (ACE_ENV_SINGLE_ARG_DECL)
135
 
{
136
 
  {
137
 
    // First check if the EC is already active, if it is not then we
138
 
    // need to return right away...
139
 
    ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
140
 
    if (this->status_ != EC_S_ACTIVE)
141
 
      return;
142
 
    this->status_ = EC_S_DESTROYING;
143
 
  }
144
 
  this->dispatching_->shutdown ();
145
 
  this->timeout_generator_->shutdown ();
146
 
  this->supplier_control_->shutdown ();
147
 
  this->consumer_control_->shutdown ();
148
 
 
149
 
  this->deactivate_supplier_admin ();
150
 
  this->deactivate_consumer_admin ();
151
 
 
152
 
  this->supplier_admin_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
153
 
  ACE_CHECK;
154
 
 
155
 
  this->consumer_admin_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
156
 
  ACE_CHECK;
157
 
 
158
 
  {
159
 
    // Wait until all the shutdown() operations return before marking
160
 
    // the EC as destroyed...
161
 
    ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
162
 
    ACE_ASSERT (this->status_ == EC_S_DESTROYING);
163
 
    this->status_ = EC_S_DESTROYED;
164
 
  }
165
 
}
166
 
 
167
 
void
168
 
TAO_EC_Event_Channel_Base::deactivate_supplier_admin (void)
169
 
{
170
 
  ACE_DECLARE_NEW_CORBA_ENV;
171
 
  ACE_TRY
172
 
    {
173
 
      PortableServer::POA_var supplier_poa =
174
 
        this->supplier_admin_->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER);
175
 
      ACE_TRY_CHECK;
176
 
      PortableServer::ObjectId_var supplier_id =
177
 
        supplier_poa->servant_to_id (this->supplier_admin_ ACE_ENV_ARG_PARAMETER);
178
 
      ACE_TRY_CHECK;
179
 
      supplier_poa->deactivate_object (supplier_id.in () ACE_ENV_ARG_PARAMETER);
180
 
      ACE_TRY_CHECK;
181
 
    }
182
 
  ACE_CATCHANY
183
 
    {
184
 
            // The deactivation can throw...
185
 
    }
186
 
  ACE_ENDTRY;
187
 
}
188
 
 
189
 
void
190
 
TAO_EC_Event_Channel_Base::deactivate_consumer_admin (void)
191
 
{
192
 
  ACE_TRY_NEW_ENV
193
 
    {
194
 
      PortableServer::POA_var consumer_poa =
195
 
        this->consumer_admin_->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER);
196
 
      ACE_TRY_CHECK;
197
 
      PortableServer::ObjectId_var consumer_id =
198
 
        consumer_poa->servant_to_id (this->consumer_admin_ ACE_ENV_ARG_PARAMETER);
199
 
      ACE_TRY_CHECK;
200
 
      consumer_poa->deactivate_object (consumer_id.in () ACE_ENV_ARG_PARAMETER);
201
 
      ACE_TRY_CHECK;
202
 
    }
203
 
  ACE_CATCHANY
204
 
    {
205
 
            // The deactivation can throw...
206
 
    }
207
 
  ACE_ENDTRY;
208
 
}
209
 
 
210
 
void
211
 
TAO_EC_Event_Channel_Base::connected (TAO_EC_ProxyPushConsumer* consumer
212
 
                                      ACE_ENV_ARG_DECL)
213
 
{
214
 
  this->consumer_admin_->peer_connected (consumer ACE_ENV_ARG_PARAMETER);
215
 
  ACE_CHECK;
216
 
  this->supplier_admin_->connected (consumer ACE_ENV_ARG_PARAMETER);
217
 
  ACE_CHECK;
218
 
  this->observer_strategy_->connected (consumer ACE_ENV_ARG_PARAMETER);
219
 
  ACE_CHECK;
220
 
}
221
 
 
222
 
void
223
 
TAO_EC_Event_Channel_Base::reconnected (TAO_EC_ProxyPushConsumer* consumer
224
 
                                        ACE_ENV_ARG_DECL)
225
 
{
226
 
  this->consumer_admin_->peer_reconnected (consumer ACE_ENV_ARG_PARAMETER);
227
 
  ACE_CHECK;
228
 
  this->supplier_admin_->reconnected (consumer ACE_ENV_ARG_PARAMETER);
229
 
  ACE_CHECK;
230
 
  this->observer_strategy_->connected (consumer ACE_ENV_ARG_PARAMETER);
231
 
  ACE_CHECK;
232
 
}
233
 
 
234
 
void
235
 
TAO_EC_Event_Channel_Base::disconnected (TAO_EC_ProxyPushConsumer* consumer
236
 
                                         ACE_ENV_ARG_DECL)
237
 
{
238
 
  this->consumer_admin_->peer_disconnected (consumer ACE_ENV_ARG_PARAMETER);
239
 
  ACE_CHECK;
240
 
  this->supplier_admin_->disconnected (consumer ACE_ENV_ARG_PARAMETER);
241
 
  ACE_CHECK;
242
 
  this->observer_strategy_->disconnected (consumer ACE_ENV_ARG_PARAMETER);
243
 
  ACE_CHECK;
244
 
}
245
 
 
246
 
void
247
 
TAO_EC_Event_Channel_Base::connected (TAO_EC_ProxyPushSupplier* supplier
248
 
                                      ACE_ENV_ARG_DECL)
249
 
{
250
 
  this->supplier_admin_->peer_connected (supplier ACE_ENV_ARG_PARAMETER);
251
 
  ACE_CHECK;
252
 
  this->consumer_admin_->connected (supplier ACE_ENV_ARG_PARAMETER);
253
 
  ACE_CHECK;
254
 
  this->observer_strategy_->connected (supplier ACE_ENV_ARG_PARAMETER);
255
 
  ACE_CHECK;
256
 
}
257
 
 
258
 
void
259
 
TAO_EC_Event_Channel_Base::reconnected (TAO_EC_ProxyPushSupplier* supplier
260
 
                                        ACE_ENV_ARG_DECL)
261
 
{
262
 
  this->supplier_admin_->peer_reconnected (supplier ACE_ENV_ARG_PARAMETER);
263
 
  ACE_CHECK;
264
 
  this->consumer_admin_->reconnected (supplier ACE_ENV_ARG_PARAMETER);
265
 
  ACE_CHECK;
266
 
  this->observer_strategy_->connected (supplier ACE_ENV_ARG_PARAMETER);
267
 
  ACE_CHECK;
268
 
}
269
 
 
270
 
void
271
 
TAO_EC_Event_Channel_Base::disconnected (TAO_EC_ProxyPushSupplier* supplier
272
 
                                         ACE_ENV_ARG_DECL)
273
 
{
274
 
  this->supplier_admin_->peer_disconnected (supplier ACE_ENV_ARG_PARAMETER);
275
 
  ACE_CHECK;
276
 
  this->consumer_admin_->disconnected (supplier ACE_ENV_ARG_PARAMETER);
277
 
  ACE_CHECK;
278
 
  this->observer_strategy_->disconnected (supplier ACE_ENV_ARG_PARAMETER);
279
 
  ACE_CHECK;
280
 
}
281
 
 
282
 
RtecEventChannelAdmin::ConsumerAdmin_ptr
283
 
TAO_EC_Event_Channel_Base::for_consumers (ACE_ENV_SINGLE_ARG_DECL)
284
 
  ACE_THROW_SPEC ((CORBA::SystemException))
285
 
{
286
 
  return this->consumer_admin_->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
287
 
}
288
 
 
289
 
RtecEventChannelAdmin::SupplierAdmin_ptr
290
 
TAO_EC_Event_Channel_Base::for_suppliers (ACE_ENV_SINGLE_ARG_DECL)
291
 
  ACE_THROW_SPEC ((CORBA::SystemException))
292
 
{
293
 
  return this->supplier_admin_->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
294
 
}
295
 
 
296
 
void
297
 
TAO_EC_Event_Channel_Base::destroy (ACE_ENV_SINGLE_ARG_DECL)
298
 
  ACE_THROW_SPEC ((CORBA::SystemException))
299
 
{
300
 
  this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
301
 
}
302
 
 
303
 
RtecEventChannelAdmin::Observer_Handle
304
 
TAO_EC_Event_Channel_Base::append_observer (
305
 
       RtecEventChannelAdmin::Observer_ptr observer
306
 
       ACE_ENV_ARG_DECL)
307
 
    ACE_THROW_SPEC ((
308
 
        CORBA::SystemException,
309
 
        RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR,
310
 
        RtecEventChannelAdmin::EventChannel::CANT_APPEND_OBSERVER))
311
 
{
312
 
  return this->observer_strategy_->append_observer (observer
313
 
                                                    ACE_ENV_ARG_PARAMETER);
314
 
}
315
 
 
316
 
void
317
 
TAO_EC_Event_Channel_Base::remove_observer (
318
 
       RtecEventChannelAdmin::Observer_Handle handle
319
 
       ACE_ENV_ARG_DECL)
320
 
    ACE_THROW_SPEC ((
321
 
        CORBA::SystemException,
322
 
        RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR,
323
 
        RtecEventChannelAdmin::EventChannel::CANT_REMOVE_OBSERVER))
324
 
{
325
 
  this->observer_strategy_->remove_observer (handle
326
 
                                             ACE_ENV_ARG_PARAMETER);
327
 
}
328
 
 
329
 
void
330
 
TAO_EC_Event_Channel_Base::for_each_consumer (
331
 
                    TAO_ESF_Worker<TAO_EC_ProxyPushSupplier> *worker
332
 
                    ACE_ENV_ARG_DECL)
333
 
  ACE_THROW_SPEC ((CORBA::SystemException))
334
 
{
335
 
  this->consumer_admin_->for_each (worker
336
 
                                   ACE_ENV_ARG_PARAMETER);
337
 
  ACE_CHECK;
338
 
}
339
 
 
340
 
void
341
 
TAO_EC_Event_Channel_Base::for_each_supplier (
342
 
                    TAO_ESF_Worker<TAO_EC_ProxyPushConsumer> *worker
343
 
                    ACE_ENV_ARG_DECL)
344
 
  ACE_THROW_SPEC ((CORBA::SystemException))
345
 
{
346
 
  this->supplier_admin_->for_each (worker
347
 
                                   ACE_ENV_ARG_PARAMETER);
348
 
  ACE_CHECK;
349
 
}