Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / performance-tests / RTEvent / lib / Supplier.cpp
blob00765d26048a1c88ad42aa87b100474d405fa5d7
1 /**
2 * @file Supplier.cpp
4 * @author Carlos O'Ryan <coryan@uci.edu>
5 */
7 #include "Supplier.h"
8 #include "Implicit_Deactivator.h"
10 Supplier::Supplier (CORBA::Long experiment_id,
11 CORBA::Long event_type,
12 CORBA::Long event_range,
13 PortableServer::POA_ptr poa)
14 : experiment_id_ (experiment_id)
15 , event_type_ (event_type)
16 , event_range_ (event_range)
17 , default_POA_ (PortableServer::POA::_duplicate (poa))
21 void
22 Supplier::connect (RtecEventChannelAdmin::EventChannel_ptr ec)
24 RtecEventChannelAdmin::SupplierAdmin_var supplier_admin =
25 ec->for_suppliers ();
28 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
29 if (!CORBA::is_nil (this->proxy_consumer_.in ()))
30 return;
32 this->proxy_consumer_ =
33 supplier_admin->obtain_push_consumer ();
36 RtecEventComm::PushSupplier_var supplier =
37 this->_this ();
39 RtecEventChannelAdmin::SupplierQOS supplier_qos;
40 supplier_qos.is_gateway = 0;
41 supplier_qos.publications.length (this->event_range_);
42 for (CORBA::Long i = 0; i != this->event_range_; ++i)
44 RtecEventComm::EventHeader& sh =
45 supplier_qos.publications[i].event.header;
46 sh.type = this->event_type_ + 2 * i;
47 sh.source = this->experiment_id_;
50 this->proxy_consumer_->connect_push_supplier (supplier.in (),
51 supplier_qos);
54 void
55 Supplier::disconnect ()
57 RtecEventChannelAdmin::ProxyPushConsumer_var proxy;
59 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
60 if (CORBA::is_nil (this->proxy_consumer_.in ()))
61 return;
62 proxy = this->proxy_consumer_._retn ();
65 Implicit_Deactivator deactivator (this);
67 try
69 proxy->disconnect_push_consumer ();
71 catch (const CORBA::Exception&){}
74 void
75 Supplier::push (const RtecEventComm::EventSet &events)
77 // ACE_DEBUG ((LM_DEBUG, "Supplier pushing (%d,%d)\n",
78 // events[0].header.type, events[0].header.source));
79 RtecEventChannelAdmin::ProxyPushConsumer_var proxy;
81 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
82 if (CORBA::is_nil (this->proxy_consumer_.in ()))
83 return;
84 proxy = this->proxy_consumer_;
87 proxy->push (events);
90 void
91 Supplier::disconnect_push_supplier ()
93 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
94 this->proxy_consumer_ =
95 RtecEventChannelAdmin::ProxyPushConsumer::_nil ();
98 PortableServer::POA_ptr
99 Supplier::_default_POA ()
101 return PortableServer::POA::_duplicate (this->default_POA_.in ());