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

« back to all changes in this revision

Viewing changes to TAO/orbsvcs/orbsvcs/Event/EC_Per_Supplier_Filter.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_Per_Supplier_Filter.cpp,v 1.21 2003/06/26 17:34:38 jwillemsen Exp
2
 
 
3
 
#include "EC_Per_Supplier_Filter.h"
4
 
#include "EC_Event_Channel_Base.h"
5
 
#include "EC_ProxySupplier.h"
6
 
#include "EC_ProxyConsumer.h"
7
 
#include "EC_Scheduling_Strategy.h"
8
 
#include "EC_QOS_Info.h"
9
 
 
10
 
#include "orbsvcs/ESF/ESF_Proxy_Collection.h"
11
 
 
12
 
#include "orbsvcs/Event_Service_Constants.h"
13
 
 
14
 
#if ! defined (__ACE_INLINE__)
15
 
#include "EC_Per_Supplier_Filter.i"
16
 
#endif /* __ACE_INLINE__ */
17
 
 
18
 
ACE_RCSID(Event, EC_Per_Supplier_Filter, "EC_Per_Supplier_Filter.cpp,v 1.21 2003/06/26 17:34:38 jwillemsen Exp")
19
 
 
20
 
TAO_EC_Per_Supplier_Filter::
21
 
    TAO_EC_Per_Supplier_Filter (TAO_EC_Event_Channel_Base* ec)
22
 
  :  event_channel_ (ec),
23
 
     consumer_ (0),
24
 
     refcnt_ (1)
25
 
{
26
 
  this->event_channel_->create_proxy_collection (this->collection_);
27
 
}
28
 
 
29
 
TAO_EC_Per_Supplier_Filter::~TAO_EC_Per_Supplier_Filter (void)
30
 
{
31
 
  this->event_channel_->destroy_proxy_collection (this->collection_);
32
 
  this->collection_ = 0;
33
 
}
34
 
 
35
 
void
36
 
TAO_EC_Per_Supplier_Filter::bind (TAO_EC_ProxyPushConsumer* consumer)
37
 
{
38
 
  ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
39
 
 
40
 
  if (this->consumer_ != 0)
41
 
    return;
42
 
 
43
 
  this->consumer_ = consumer;
44
 
}
45
 
 
46
 
void
47
 
TAO_EC_Per_Supplier_Filter::unbind (TAO_EC_ProxyPushConsumer* consumer)
48
 
{
49
 
  ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
50
 
 
51
 
  if (this->consumer_ == 0 || this->consumer_ != consumer)
52
 
    return;
53
 
 
54
 
  this->consumer_ = 0;
55
 
 
56
 
  ACE_TRY_NEW_ENV
57
 
    {
58
 
      this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
59
 
      ACE_TRY_CHECK;
60
 
    }
61
 
  ACE_CATCHANY
62
 
    {
63
 
      // @@ Ignore exceptions
64
 
    }
65
 
  ACE_ENDTRY;
66
 
}
67
 
 
68
 
void
69
 
TAO_EC_Per_Supplier_Filter::connected (TAO_EC_ProxyPushSupplier* supplier
70
 
                                       ACE_ENV_ARG_DECL)
71
 
{
72
 
  ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
73
 
 
74
 
  if (this->consumer_ == 0)
75
 
    return;
76
 
 
77
 
  const RtecEventChannelAdmin::SupplierQOS& pub =
78
 
    this->consumer_->publications_i ();
79
 
 
80
 
  for (CORBA::ULong j = 0; j < pub.publications.length (); ++j)
81
 
    {
82
 
      const RtecEventComm::Event& event =
83
 
        pub.publications[j].event;
84
 
 
85
 
#if TAO_EC_ENABLE_DEBUG_MESSAGES
86
 
      ACE_DEBUG ((LM_DEBUG, "Connecting consumer <%x> to <%x>, "
87
 
                  "trying event <%d:%d>  ",
88
 
                  supplier, this,
89
 
                  event.header.source, event.header.type));
90
 
#endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */
91
 
      if (supplier->can_match (event.header))
92
 
        {
93
 
#if TAO_EC_ENABLE_DEBUG_MESSAGES
94
 
          ACE_DEBUG ((LM_DEBUG, "  matched\n"));
95
 
#endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */
96
 
          this->collection_->connected (supplier ACE_ENV_ARG_PARAMETER);
97
 
          ACE_CHECK;
98
 
          return;
99
 
        }
100
 
#if TAO_EC_ENABLE_DEBUG_MESSAGES
101
 
      ACE_DEBUG ((LM_DEBUG, "  not matched\n"));
102
 
#endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */
103
 
    }
104
 
}
105
 
 
106
 
void
107
 
TAO_EC_Per_Supplier_Filter::reconnected (TAO_EC_ProxyPushSupplier* supplier
108
 
                                         ACE_ENV_ARG_DECL)
109
 
{
110
 
  ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
111
 
 
112
 
  if (this->consumer_ == 0)
113
 
    return;
114
 
 
115
 
  const RtecEventChannelAdmin::SupplierQOS& pub =
116
 
    this->consumer_->publications_i ();
117
 
 
118
 
  for (CORBA::ULong j = 0; j < pub.publications.length (); ++j)
119
 
    {
120
 
      const RtecEventComm::Event& event =
121
 
        pub.publications[j].event;
122
 
 
123
 
      //      ACE_DEBUG ((LM_DEBUG, "Trying %d:%d in %x\n",
124
 
      //                  event.header.source, event.header.type,
125
 
      //                  this));
126
 
      if (supplier->can_match (event.header))
127
 
        {
128
 
          //          ACE_DEBUG ((LM_DEBUG, "  matched %x\n", supplier));
129
 
          this->collection_->connected (supplier ACE_ENV_ARG_PARAMETER);
130
 
          ACE_CHECK;
131
 
          return;
132
 
        }
133
 
    }
134
 
  this->collection_->disconnected (supplier ACE_ENV_ARG_PARAMETER);
135
 
}
136
 
 
137
 
void
138
 
TAO_EC_Per_Supplier_Filter::disconnected (TAO_EC_ProxyPushSupplier* supplier
139
 
                                          ACE_ENV_ARG_DECL)
140
 
{
141
 
  this->collection_->disconnected (supplier ACE_ENV_ARG_PARAMETER);
142
 
}
143
 
 
144
 
void
145
 
TAO_EC_Per_Supplier_Filter::shutdown (ACE_ENV_SINGLE_ARG_DECL)
146
 
{
147
 
  this->collection_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
148
 
}
149
 
 
150
 
void
151
 
TAO_EC_Per_Supplier_Filter::push (const RtecEventComm::EventSet& event,
152
 
                                  TAO_EC_ProxyPushConsumer *consumer
153
 
                                  ACE_ENV_ARG_DECL)
154
 
{
155
 
  TAO_EC_Scheduling_Strategy* scheduling_strategy =
156
 
    this->event_channel_->scheduling_strategy ();
157
 
  scheduling_strategy->schedule_event (event,
158
 
                                       consumer,
159
 
                                       this
160
 
                                       ACE_ENV_ARG_PARAMETER);
161
 
}
162
 
 
163
 
void
164
 
TAO_EC_Per_Supplier_Filter::push_scheduled_event (RtecEventComm::EventSet &event,
165
 
                                                  const TAO_EC_QOS_Info &event_info
166
 
                                                  ACE_ENV_ARG_DECL)
167
 
{
168
 
  TAO_EC_Filter_Worker worker (event, event_info);
169
 
  this->collection_->for_each (&worker ACE_ENV_ARG_PARAMETER);
170
 
}
171
 
 
172
 
CORBA::ULong
173
 
TAO_EC_Per_Supplier_Filter::_incr_refcnt (void)
174
 
{
175
 
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
176
 
 
177
 
  this->refcnt_++;
178
 
  return this->refcnt_;
179
 
}
180
 
 
181
 
CORBA::ULong
182
 
TAO_EC_Per_Supplier_Filter::_decr_refcnt (void)
183
 
{
184
 
  {
185
 
    ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
186
 
 
187
 
    this->refcnt_--;
188
 
    if (this->refcnt_ != 0)
189
 
      return this->refcnt_;
190
 
  }
191
 
  this->event_channel_->supplier_filter_builder ()->destroy (this);
192
 
  return 0;
193
 
}
194
 
 
195
 
// ****************************************************************
196
 
 
197
 
TAO_EC_Supplier_Filter*
198
 
TAO_EC_Per_Supplier_Filter_Builder::create (
199
 
    RtecEventChannelAdmin::SupplierQOS&)
200
 
{
201
 
  return new TAO_EC_Per_Supplier_Filter (this->event_channel_);
202
 
}
203
 
 
204
 
void
205
 
TAO_EC_Per_Supplier_Filter_Builder::destroy (
206
 
    TAO_EC_Supplier_Filter* x)
207
 
{
208
 
  delete x;
209
 
}