diff options
author | michel_j <michel_j@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-07-01 20:13:11 +0000 |
---|---|---|
committer | michel_j <michel_j@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-07-01 20:13:11 +0000 |
commit | c1eb8ab20e76266f9e5b0a1009bfc2e1c93f7aa0 (patch) | |
tree | 27aaea0cca31b544397fe079ece67ca0b6678ebd /TAO/orbsvcs | |
parent | 70424f8e426ecd24b30dcdea12c1caa7d37abc57 (diff) | |
download | ATCD-c1eb8ab20e76266f9e5b0a1009bfc2e1c93f7aa0.tar.gz |
ChangeLogTag: Fri Jul 1 14:43:27 2005 Justin Michel <michel_j@ociweb.com>
Diffstat (limited to 'TAO/orbsvcs')
173 files changed, 1803 insertions, 2473 deletions
diff --git a/TAO/orbsvcs/Notify_Service/Notify_Service.cpp b/TAO/orbsvcs/Notify_Service/Notify_Service.cpp index a7e7770a6f4..ce738fed6e5 100644 --- a/TAO/orbsvcs/Notify_Service/Notify_Service.cpp +++ b/TAO/orbsvcs/Notify_Service/Notify_Service.cpp @@ -94,7 +94,7 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] return -1; } - this->notify_service_->init (this->orb_.in () ACE_ENV_ARG_PARAMETER); + this->notify_service_->init_service (this->orb_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); if (this->nthreads_ > 0) // we have chosen to run in a thread pool. diff --git a/TAO/orbsvcs/Notify_Service/README b/TAO/orbsvcs/Notify_Service/README index 61c8998f1dc..b83e208ac12 100644 --- a/TAO/orbsvcs/Notify_Service/README +++ b/TAO/orbsvcs/Notify_Service/README @@ -113,16 +113,8 @@ The svc.conf options: The "Notify_Default_Event_Manager_Objects_Factory" service object accepts the following options: -"-MTDispatching" : Enable MT dispatching "-DispatchingThreads [thread_count]" : How many threads for MT dispatching. -"-MTSourceEval" : Enable MT proxy consumer(source) filter evaluation. -"-SourceThreads [thread_count]" : How many threads for source filter evaluation. - -"-MTLookup" : Enable MT subscription table lookup. -"-LookupThreads [thread_count]" : How many lookup threads. - -"-MTListenerEval" : Enable MT proxy supplier (listener) filter evaluation. "-ListenerThreads" : How many threads for listener filter evaluation. "-AsynchUpdates" : Send subscription and @@ -130,27 +122,33 @@ The "Notify_Default_Event_Manager_Objects_Factory" service object accepts the fo asynchronously. "-AllocateTaskperProxy" : Allocate worker tasks per - proxy for the following - options: - "-MTDispatching", - "-MTSourceEval" - "-MTListenerEval" + proxy *see footnote below for explanation* +"-AllowReconnect" : Allows consumers and suppliers to + reconnect to existing proxies. + +"-NoUpdates" : Globally disables subscription and + publication updates. + +All other options are deprecated and should not be used. e.g. svc.conf -static Notify_Default_Event_Manager_Objects_Factory "-MTSourceEval -MTDispatching -DispatchingThreads 2" +static Notify_Default_Event_Manager_Objects_Factory "-DispatchingThreads 2" -This means that we want to enable MT proxy supplier filter evaluation -(default 1 thread) and MT event dispatching with 2 threads. +This means that we want to enable event dispatching with 2 threads. ---------------------------------------------------------------- What does the "-AllocateTaskperProxy" option do? A Task here implies a thread pool that performs a fixed work in the Notify. -e.g. When you specify "-MTDispatching" and set "DispatchingThreads 1". +e.g. When you specify "DispatchingThreads 1". It means that there is 1 thread to perform the event dispatching to -consumers IRRESPECTIVE OF THE NUMBER OF PROXYSUPPLIERS. +consumers IRRESPECTIVE OF THE NUMBER OF PROXYSUPPLIERS. It also means that +events destined for each consumer will be queued to a buffer for that consumer. +Therefore, you can also think of this option as Enable Consumer-side Buffering +of Events. + This is the default case. When you specify "-AllocateTaskperProxy" it asks notify to create a @@ -160,18 +158,17 @@ PROXYSUPPLIER. So if you use this option and connect 50 consumers with threads! so use this option with care and you might not need it in most cases. -why have this feature in the first place? The intent is to allow the +Why have this feature in the first place? The intent is to allow the software architect of a Notify based system, fine control over where and how much thread resources are deployed. e.g. a channel could have 2 proxy suppliers - the first one delivers an important event in huge quantities. A dedicated thread pool to this proxy will ensure better -throughput to it's consumers. (Eventually i want to be able to set the +throughput to it's consumers. (Eventually I want to be able to set the thread pool size via a QoS property) - -Similarly, the "-MTSourceEval" specifies a thread pool for the filter -evaluation at the proxyconsumer ("Source"). -and the "-MTListenerEval" specifies a thread pool for the filter -evaluation at the proxyconsumer ("Listener"). +Similarly "-ListenerThreads 2" specifies a thread pool for use by +the supplier-side processing. This enables Buffering on the Supplier-side, with +the thread pool being used to process supplier side filters and push the +events to the Consumer side. How to use the NT_Notify_Service ================================ diff --git a/TAO/orbsvcs/Notify_Service/svc.conf b/TAO/orbsvcs/Notify_Service/svc.conf index fbe7d7f3a57..8d973e09c33 100644 --- a/TAO/orbsvcs/Notify_Service/svc.conf +++ b/TAO/orbsvcs/Notify_Service/svc.conf @@ -1,3 +1,3 @@ ## $Id$ -static Notify_Default_Event_Manager_Objects_Factory "-MTDispatching -DispatchingThreads 1" +static Notify_Default_Event_Manager_Objects_Factory "-DispatchingThreads 1" diff --git a/TAO/orbsvcs/Notify_Service/svc.conf.xml b/TAO/orbsvcs/Notify_Service/svc.conf.xml index 43ae631882c..237d7598804 100644 --- a/TAO/orbsvcs/Notify_Service/svc.conf.xml +++ b/TAO/orbsvcs/Notify_Service/svc.conf.xml @@ -1,5 +1,5 @@ <?xml version='1.0'?> <!-- Converted from ./orbsvcs/Notify_Service/svc.conf by svcconf-convert.pl --> <ACE_Svc_Conf> - <static id="Notify_Default_Event_Manager_Objects_Factory" params="-MTDispatching -DispatchingThreads 1"/> + <static id="Notify_Default_Event_Manager_Objects_Factory" params="-DispatchingThreads 1"/> </ACE_Svc_Conf> diff --git a/TAO/orbsvcs/orbsvcs/CosNotification.mpc b/TAO/orbsvcs/orbsvcs/CosNotification.mpc index a6eafa4afdc..cc835d9255e 100644 --- a/TAO/orbsvcs/orbsvcs/CosNotification.mpc +++ b/TAO/orbsvcs/orbsvcs/CosNotification.mpc @@ -234,7 +234,6 @@ project(CosNotification_Serv) : orbsvcslib, svc_utils, core, notification_skel, Notify/Any/ProxyPushSupplier.cpp Notify/Any/PushConsumer.cpp Notify/Any/PushSupplier.cpp - Notify/Sequence/Batch_Buffering_Strategy.cpp Notify/Sequence/SequenceProxyPushConsumer.cpp Notify/Sequence/SequenceProxyPushSupplier.cpp Notify/Sequence/SequencePushConsumer.cpp diff --git a/TAO/orbsvcs/orbsvcs/CosNotifyComm.idl b/TAO/orbsvcs/orbsvcs/CosNotifyComm.idl index e5787489790..59a19564db8 100644 --- a/TAO/orbsvcs/orbsvcs/CosNotifyComm.idl +++ b/TAO/orbsvcs/orbsvcs/CosNotifyComm.idl @@ -106,6 +106,7 @@ module CosNotifyComm CosEventComm::PushConsumer { }; +#ifdef TAO_HAS_NOTIFY_PULL_INTERFACES /** * @interface PullConsumer * @@ -131,7 +132,7 @@ module CosNotifyComm NotifySubscribe, CosEventComm::PullSupplier { }; - +#endif /* TAO_HAS_NOTIFY_PULL_INTERFACES */ /** * @interface PushSupplier * @@ -176,6 +177,7 @@ module CosNotifyComm void disconnect_structured_push_consumer(); }; +#ifdef TAO_HAS_NOTIFY_PULL_INTERFACES /** * @interface StructuredPullConsumer * @@ -239,6 +241,7 @@ module CosNotifyComm */ void disconnect_structured_pull_supplier(); }; +#endif /* TAO_HAS_NOTIFY_PULL_INTERFACES */ /** * @interface StructuredPushSupplier diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp b/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp index b19dccf80b0..5183e0e8f35 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp @@ -25,7 +25,6 @@ ACE_RCSID (Notify, TAO_Notify_Admin::TAO_Notify_Admin () : ec_ (0) - , proxy_container_ (0) , filter_operator_ (CosNotifyChannelAdmin::OR_OP) , is_default_ (false) { @@ -36,26 +35,27 @@ TAO_Notify_Admin::TAO_Notify_Admin () TAO_Notify_Admin::~TAO_Notify_Admin () { - this->ec_->_decr_refcnt (); } void -TAO_Notify_Admin::init (TAO_Notify::Topology_Parent * parent ACE_ENV_ARG_DECL) +TAO_Notify_Admin::init (TAO_Notify::Topology_Parent* parent ACE_ENV_ARG_DECL) { - this->ec_ = dynamic_cast<TAO_Notify_EventChannel *> (parent); - ACE_ASSERT (this->ec_ != 0); + ACE_ASSERT (this->ec_.get() == 0); - this->ec_->_incr_refcnt (); + this->ec_.reset (dynamic_cast<TAO_Notify_EventChannel *>(parent)); + ACE_ASSERT (this->ec_.get() != 0); // this-> on the following line confuses VC6 initialize (parent ACE_ENV_ARG_PARAMETER); - ACE_NEW_THROW_EX (this->proxy_container_, + TAO_Notify_Proxy_Container* proxy_container = 0; + ACE_NEW_THROW_EX (proxy_container, TAO_Notify_Proxy_Container (), CORBA::INTERNAL ()); ACE_CHECK; + this->proxy_container_.reset (proxy_container); - this->proxy_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + this->proxy_container().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; } @@ -63,7 +63,7 @@ TAO_Notify_Admin::init (TAO_Notify::Topology_Parent * parent ACE_ENV_ARG_DECL) void TAO_Notify_Admin::remove (TAO_Notify_Proxy* proxy ACE_ENV_ARG_DECL) { - this->proxy_container_->remove (proxy ACE_ENV_ARG_PARAMETER); + this->proxy_container().remove (proxy ACE_ENV_ARG_PARAMETER); ACE_CHECK; } @@ -88,18 +88,16 @@ TAO_Notify_Admin::shutdown (ACE_ENV_SINGLE_ARG_DECL) if (TAO_Notify_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) return 1; - this->proxy_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + this->proxy_container().shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (1); - delete this->proxy_container_; - return 0; } void TAO_Notify_Admin::insert (TAO_Notify_Proxy* proxy ACE_ENV_ARG_DECL) { - this->proxy_container_->insert (proxy ACE_ENV_ARG_PARAMETER); + this->proxy_container().insert (proxy ACE_ENV_ARG_PARAMETER); } void @@ -132,7 +130,7 @@ TAO_Notify_Admin::save_persistent (TAO_Notify::Topology_Saver& saver ACE_ENV_ARG } TAO_Notify::Save_Persist_Worker<TAO_Notify_Proxy> wrk(saver, want_all_children); - this->proxy_container_->collection()->for_each(&wrk ACE_ENV_ARG_PARAMETER); + this->proxy_container().collection()->for_each(&wrk ACE_ENV_ARG_PARAMETER); ACE_CHECK; saver.end_object(this->id(), type ACE_ENV_ARG_PARAMETER); @@ -154,7 +152,7 @@ void TAO_Notify_Admin::load_attrs(const TAO_Notify::NVPList& attrs) { TAO_Notify_Object::load_attrs (attrs); - const char * value = 0; + const char* value = 0; if (attrs.find ("InterFilterGroupOperator", value)) { this->filter_operator_ = static_cast <CosNotifyChannelAdmin::InterFilterGroupOperator> (ACE_OS::atoi (value)); @@ -197,18 +195,7 @@ void TAO_Notify_Admin::reconnect (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify::Reconnect_Worker<TAO_Notify_Proxy> wrk; - this->proxy_container_->collection()->for_each(&wrk ACE_ENV_ARG_PARAMETER); + this->proxy_container().collection()->for_each(&wrk ACE_ENV_ARG_PARAMETER); ACE_CHECK; } -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class TAO_ESF_Shutdown_Proxy<TAO_Notify_Proxy>; -template class TAO_Notify_Container_T <TAO_Notify_Proxy>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma TAO_ESF_Shutdown_Proxy<TAO_Notify_Proxy> -#pragma instantiate TAO_Notify_Container_T <TAO_Notify_Proxy> - -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.h b/TAO/orbsvcs/orbsvcs/Notify/Admin.h index 3e67f4303ed..3af6e864fae 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Admin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.h @@ -23,9 +23,10 @@ #include "FilterAdmin.h" #include "EventTypeSeq.h" #include "Topology_Object.h" +#include "EventChannel.h" + class TAO_Notify_Proxy; -class TAO_Notify_EventChannel; template <class TYPE> class TAO_Notify_Container_T; /** @@ -46,7 +47,7 @@ public: TAO_Notify_Admin (); /// Destructor - ~TAO_Notify_Admin (); + virtual ~TAO_Notify_Admin (); /// Init void init (TAO_Notify::Topology_Parent * parent ACE_ENV_ARG_DECL); @@ -89,17 +90,14 @@ protected: void save_attrs (TAO_Notify::NVPList& attrs); virtual const char * get_admin_type_name (void) const = 0; -protected: - typedef TAO_Notify_Container_T <TAO_Notify_Proxy> - TAO_Notify_Proxy_Container; + typedef TAO_Notify_Container_T<TAO_Notify_Proxy> TAO_Notify_Proxy_Container; + TAO_Notify_Proxy_Container& proxy_container(); /// = Data Members /// The EventChannel. - TAO_Notify_EventChannel *ec_; + TAO_Notify_EventChannel::Ptr ec_; - /// The Proxy Container. - TAO_Notify_Proxy_Container *proxy_container_; /// The types that we've subscribed our proxy objects with the event manager. TAO_Notify_EventTypeSeq subscribed_types_; @@ -111,6 +109,9 @@ protected: CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator_; bool is_default_; +private: + /// The Proxy Container. + ACE_Auto_Ptr< TAO_Notify_Proxy_Container > proxy_container_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.inl b/TAO/orbsvcs/orbsvcs/Notify/Admin.inl index f675842ad8c..eef513ea103 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Admin.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.inl @@ -4,7 +4,7 @@ ACE_INLINE TAO_Notify_EventChannel * TAO_Notify_Admin::event_channel () const { - return this->ec_; + return this->ec_.get(); } @@ -39,3 +39,10 @@ TAO_Notify_Admin::is_default (void) const { return this->is_default_; } + +ACE_INLINE TAO_Notify_Admin::TAO_Notify_Proxy_Container& +TAO_Notify_Admin::proxy_container() +{ + ACE_ASSERT( proxy_container_.get() != 0 ); + return *proxy_container_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp index 1c90b0e5248..afb3a1cb63a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp @@ -18,7 +18,7 @@ TAO_Notify_AdminProperties::TAO_Notify_AdminProperties (void) , max_suppliers_ (CosNotification::MaxSuppliers, 0) , reject_new_events_ (CosNotification::RejectNewEvents, 0) , global_queue_length_ (0) - , global_queue_not_full_condition_ (global_queue_lock_) + , global_queue_not_full_ (global_queue_lock_) { } @@ -83,22 +83,8 @@ TAO_Notify_AdminProperties::queue_full (void) if (this->max_global_queue_length () == 0) return 0; else - if (this->global_queue_length_ > this->max_global_queue_length ().value ()) + if (this->global_queue_length_ >= this->max_global_queue_length ().value ()) return 1; return 0; } - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class ACE_Atomic_Op<TAO_SYNCH_MUTEX,int>; -template class ACE_Atomic_Op_Ex<TAO_SYNCH_MUTEX,int>; -template class ACE_Refcounted_Auto_Ptr<TAO_Notify_AdminProperties, TAO_SYNCH_MUTEX>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate ACE_Atomic_Op<TAO_SYNCH_MUTEX,int> -#pragma instantiate ACE_Atomic_Op_Ex<TAO_SYNCH_MUTEX,int> -#pragma ACE_Refcounted_Auto_Ptr<TAO_Notify_AdminProperties, TAO_SYNCH_MUTEX> - -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h index 5594add39b6..0361cfc5d46 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h @@ -20,17 +20,17 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/Atomic_Op.h" -#include "ace/Refcounted_Auto_Ptr.h" -#include "ace/Condition_Thread_Mutex.h" - -#include "tao/orbconf.h" - #include "PropertySeq.h" #include "Property_T.h" #include "Property.h" #include "Property_Boolean.h" +#include "tao/orbconf.h" + +#include "ace/Atomic_Op.h" +#include "ace/Bound_Ptr.h" +#include "ace/Condition_Thread_Mutex.h" + /** * @class TAO_Notify_AdminProperties * @@ -41,11 +41,12 @@ class TAO_Notify_Serv_Export TAO_Notify_AdminProperties : public TAO_Notify_PropertySeq { public: + typedef ACE_Strong_Bound_Ptr<TAO_Notify_AdminProperties, TAO_SYNCH_MUTEX> Ptr; /// Constuctor TAO_Notify_AdminProperties (void); /// Destructor - ~TAO_Notify_AdminProperties (); + virtual ~TAO_Notify_AdminProperties (); // Init int init (const CosNotification::PropertySeq& prop_seq); @@ -67,7 +68,7 @@ public: CORBA::Long& global_queue_length (void); TAO_SYNCH_MUTEX& global_queue_lock (void); - TAO_SYNCH_CONDITION& global_queue_not_full_condition (void); + TAO_SYNCH_CONDITION& global_queue_not_full (void); TAO_Notify_Atomic_Property_Long& consumers (void); TAO_Notify_Atomic_Property_Long& suppliers (void); @@ -110,7 +111,7 @@ protected: TAO_SYNCH_MUTEX global_queue_lock_; /// The condition that the queue_length_ is not at max. - TAO_SYNCH_CONDITION global_queue_not_full_condition_; + TAO_SYNCH_CONDITION global_queue_not_full_; /// These are used to count the number of consumers and suppliers connected to /// the system. @@ -118,9 +119,6 @@ protected: TAO_Notify_Atomic_Property_Long suppliers_; }; -typedef ACE_Refcounted_Auto_Ptr<TAO_Notify_AdminProperties, - TAO_SYNCH_MUTEX> - TAO_Notify_AdminProperties_var; #if defined (__ACE_INLINE__) #include "AdminProperties.inl" diff --git a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl index 36743cc9dc1..e88a34cec6a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl @@ -61,9 +61,9 @@ TAO_Notify_AdminProperties::global_queue_lock (void) } ACE_INLINE TAO_SYNCH_CONDITION& -TAO_Notify_AdminProperties::global_queue_not_full_condition (void) +TAO_Notify_AdminProperties::global_queue_not_full(void) { - return this->global_queue_not_full_condition_; + return this->global_queue_not_full_; } ACE_INLINE TAO_Notify_Atomic_Property_Long& diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.cpp index de4b9b46faa..0d67af83add 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.cpp @@ -132,10 +132,3 @@ TAO_Notify_AnyEvent::TAO_Notify_AnyEvent (const CORBA::Any &event) TAO_Notify_AnyEvent::~TAO_Notify_AnyEvent () { } - -const TAO_Notify_Event * -TAO_Notify_AnyEvent::queueable_copy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const -{ - return this; -} - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.h b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.h index 3b56a9bedaf..a66d994474c 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.h @@ -41,7 +41,7 @@ public: TAO_Notify_AnyEvent_No_Copy (const CORBA::Any &event); /// Destructor - ~TAO_Notify_AnyEvent_No_Copy (); + virtual ~TAO_Notify_AnyEvent_No_Copy (); /// Get the event type. virtual const TAO_Notify_EventType& type (void) const; @@ -103,10 +103,7 @@ public: TAO_Notify_AnyEvent (const CORBA::Any &event); /// Destructor - ~TAO_Notify_AnyEvent (); - - /// return this - virtual const TAO_Notify_Event * queueable_copy (ACE_ENV_SINGLE_ARG_DECL)const; + virtual ~TAO_Notify_AnyEvent (); protected: /// Copy of the Event. diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.cpp index 6da0cae1abc..a68926d13da 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.cpp @@ -34,8 +34,8 @@ TAO_Notify_CosEC_ProxyPushConsumer::push (const CORBA::Any& any ACE_ENV_ARG_DECL )) { // Check if we should proceed at all. - if (this->admin_properties_->reject_new_events () == 1 - && this->admin_properties_->queue_full ()) + if (this->admin_properties().reject_new_events () == 1 + && this->admin_properties().queue_full ()) ACE_THROW (CORBA::IMP_LIMIT ()); if (this->is_connected () == 0) @@ -47,7 +47,7 @@ TAO_Notify_CosEC_ProxyPushConsumer::push (const CORBA::Any& any ACE_ENV_ARG_DECL TAO_Notify_Method_Request_Lookup_No_Copy request (&event, this); - this->worker_task ()->execute (request ACE_ENV_ARG_PARAMETER); + this->execute_task (request ACE_ENV_ARG_PARAMETER); } void @@ -75,6 +75,7 @@ TAO_Notify_CosEC_ProxyPushConsumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG CORBA::SystemException )) { + TAO_Notify_CosEC_ProxyPushConsumer::Ptr guard( this ); this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.h index 09a776facc0..47dfb5c400f 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.h @@ -44,10 +44,8 @@ public: TAO_Notify_CosEC_ProxyPushConsumer (void); /// Destructor - ~TAO_Notify_CosEC_ProxyPushConsumer (); + virtual ~TAO_Notify_CosEC_ProxyPushConsumer (); - /// Release - virtual void release (void); virtual const char * get_proxy_type_name (void) const; @@ -71,9 +69,8 @@ protected: CORBA::SystemException )); private: - // Overloaded TAO_Notify_ProxyConsumer::push to get around Borland compiler warnings. - // I don't think this is necessary any more -- Dale. -// virtual void push (TAO_Notify_Event_var &event); + /// Release + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.cpp index 73db5b163a5..b6bc7eaffcc 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.cpp @@ -18,7 +18,6 @@ TAO_Notify_CosEC_ProxyPushSupplier::~TAO_Notify_CosEC_ProxyPushSupplier () void TAO_Notify_CosEC_ProxyPushSupplier::release (void) { - this->consumer_->release (); delete this; //@@ inform factory @@ -51,6 +50,7 @@ TAO_Notify_CosEC_ProxyPushSupplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG CORBA::SystemException )) { + TAO_Notify_CosEC_ProxyPushSupplier::Ptr guard( this ); this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.h index f5be1d66936..a216d9f9527 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.h @@ -49,10 +49,7 @@ public: TAO_Notify_CosEC_ProxyPushSupplier (void); /// Destructor - ~TAO_Notify_CosEC_ProxyPushSupplier (); - - /// Release - virtual void release (void); + virtual ~TAO_Notify_CosEC_ProxyPushSupplier (); virtual const char * get_proxy_type_name (void) const; @@ -73,6 +70,10 @@ public: ACE_THROW_SPEC (( CORBA::SystemException )); + +private: + /// Release + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.cpp index 692927519a0..4101bd52b2f 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.cpp @@ -21,8 +21,6 @@ TAO_Notify_ProxyPushConsumer::~TAO_Notify_ProxyPushConsumer () void TAO_Notify_ProxyPushConsumer::release (void) { - if (this->supplier_) - this->supplier_->release (); delete this; //@@ inform factory @@ -45,8 +43,8 @@ TAO_Notify_ProxyPushConsumer::push (const CORBA::Any& any ACE_ENV_ARG_DECL) )) { // Check if we should proceed at all. - if (this->admin_properties_->reject_new_events () == 1 - && this->admin_properties_->queue_full ()) + if (this->admin_properties().reject_new_events () == 1 + && this->admin_properties().queue_full ()) ACE_THROW (CORBA::IMP_LIMIT ()); if (this->is_connected () == 0) @@ -84,6 +82,7 @@ void TAO_Notify_ProxyPushConsumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_ CORBA::SystemException )) { + TAO_Notify_ProxyPushConsumer::Ptr guard( this ); this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.h index 919ea3d6951..1766a878f1a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.h @@ -46,10 +46,8 @@ public: TAO_Notify_ProxyPushConsumer (void); /// Destructor - ~TAO_Notify_ProxyPushConsumer (); + virtual ~TAO_Notify_ProxyPushConsumer (); - /// Release - virtual void release (void); // virtual void save_persistent (TAO_Notify::Topology_Saver& saver ACE_ENV_ARG_DECL); virtual const char * get_proxy_type_name (void) const; @@ -82,9 +80,8 @@ protected: )); private: - // Overloaded TAO_Notify_ProxyConsumer::push to get around Borland compiler warnings. - // I don't think this is necessary any more -- Dale. -// virtual void push (TAO_Notify_Event_var &event); + /// Release + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.cpp index 982ef04e1ee..10180736830 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.cpp @@ -19,8 +19,6 @@ TAO_Notify_ProxyPushSupplier::~TAO_Notify_ProxyPushSupplier () void TAO_Notify_ProxyPushSupplier::release (void) { - if (this->consumer_) - this->consumer_->release (); delete this; //@@ inform factory @@ -55,6 +53,7 @@ TAO_Notify_ProxyPushSupplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL) CORBA::SystemException )) { + TAO_Notify_ProxyPushSupplier::Ptr guard( this ); this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.h index aed52bd19d7..82dd07722ad 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.h @@ -51,10 +51,7 @@ public: TAO_Notify_ProxyPushSupplier (void); /// Destructor - ~TAO_Notify_ProxyPushSupplier (); - - /// TAO_Notify_Destroy_Callback methods - virtual void release (void); + virtual ~TAO_Notify_ProxyPushSupplier (); virtual const char * get_proxy_type_name (void) const; @@ -82,6 +79,10 @@ public: ACE_THROW_SPEC (( CORBA::SystemException )); + +private: + /// TAO_Notify_Destroy_Callback methods + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.cpp index 07701320013..a912b7f5706 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.cpp @@ -6,7 +6,7 @@ ACE_RCSID (Notify, TAO_Notify_PushConsumer, "$Id$") -#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Bound_Ptr.h" #include "orbsvcs/CosEventCommC.h" #include "../Event.h" #include "../Properties.h" @@ -23,6 +23,8 @@ TAO_Notify_PushConsumer::~TAO_Notify_PushConsumer () void TAO_Notify_PushConsumer::init (CosEventComm::PushConsumer_ptr push_consumer ACE_ENV_ARG_DECL) { + ACE_ASSERT ( push_consumer != 0 && this->push_consumer_.in() == 0 ); + this->push_consumer_ = CosEventComm::PushConsumer::_duplicate (push_consumer); ACE_TRY diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.h index 37967cc8d3b..b159ad6e702 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.h @@ -35,13 +35,11 @@ public: TAO_Notify_PushConsumer (TAO_Notify_ProxySupplier* proxy); /// Destructor - ~TAO_Notify_PushConsumer (); + virtual ~TAO_Notify_PushConsumer (); /// Init void init (CosEventComm::PushConsumer_ptr push_consumer ACE_ENV_ARG_DECL); - /// TAO_Notify_Destroy_Callback methods. - virtual void release (void); /// Push <event> to this consumer. // virtual void push_i (const TAO_Notify_Event* event ACE_ENV_ARG_DECL); @@ -67,6 +65,10 @@ public: protected: /// The Consumer CosEventComm::PushConsumer_var push_consumer_; + +private: + /// TAO_Notify_Destroy_Callback methods. + virtual void release (void); }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.cpp index e7fd70cd7af..a554c4cc2cc 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.cpp @@ -17,6 +17,8 @@ TAO_Notify_PushSupplier::~TAO_Notify_PushSupplier () void TAO_Notify_PushSupplier::init (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) { + ACE_ASSERT (push_supplier != 0 && this->push_supplier_.in() == 0); + this->push_supplier_ = CosEventComm::PushSupplier::_duplicate (push_supplier); ACE_TRY diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.h index a0726ccda2e..9c5cf56d9bc 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.h @@ -38,13 +38,11 @@ public: TAO_Notify_PushSupplier (TAO_Notify_ProxyConsumer* proxy); /// Destructor - ~TAO_Notify_PushSupplier (); + virtual ~TAO_Notify_PushSupplier (); /// Init void init (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL); - /// TAO_Notify_Destroy_Callback methods - virtual void release (void); /// Retrieve the ior of this peer virtual bool get_ior (ACE_CString & iorstr) const; @@ -52,6 +50,10 @@ public: protected: /// The Supplier CosEventComm::PushSupplier_var push_supplier_; + +private: + /// TAO_Notify_Destroy_Callback methods + virtual void release (void); }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp index 83cef826e15..96a73759688 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp @@ -2,43 +2,37 @@ #include "Buffering_Strategy.h" -#if ! defined (__ACE_INLINE__) -#include "Buffering_Strategy.inl" -#endif /* __ACE_INLINE__ */ +ACE_RCSID (Notify, Buffering_Strategy, "$Id$") -ACE_RCSID (Notify, - Buffering_Strategy, - "$Id$") - -#include "ace/Message_Queue.h" - -#include "orbsvcs/CosNotificationC.h" #include "Method_Request.h" #include "Notify_Extensions.h" #include "QoSProperties.h" +#include "Notify_Extensions.h" + +#include "orbsvcs/CosNotificationC.h" +#include "orbsvcs/Time_Utilities.h" #include "tao/debug.h" +#include "ace/Message_Queue.h" + TAO_Notify_Buffering_Strategy::TAO_Notify_Buffering_Strategy ( TAO_Notify_Message_Queue& msg_queue, - TAO_Notify_AdminProperties_var& admin_properties, - CORBA::Long batch_size - ) - : msg_queue_ (msg_queue), - admin_properties_ (admin_properties), - global_queue_lock_ (admin_properties->global_queue_lock ()), - global_queue_not_full_condition_ (admin_properties->global_queue_not_full_condition ()), - global_queue_length_ (admin_properties->global_queue_length ()), - max_global_queue_length_ (admin_properties->max_global_queue_length ()), - max_local_queue_length_ (0), - order_policy_ (CosNotification::OrderPolicy, CosNotification::AnyOrder), - discard_policy_ (CosNotification::DiscardPolicy, CosNotification::AnyOrder), - use_discarding_ (1), - local_queue_not_full_condition_ (global_queue_lock_), - batch_size_ (batch_size), - batch_size_reached_condition_ (global_queue_lock_), - shutdown_ (0) + TAO_Notify_AdminProperties::Ptr& admin_properties) + : msg_queue_ (msg_queue) + , admin_properties_ (admin_properties) + , global_queue_lock_ (admin_properties->global_queue_lock ()) + , global_queue_length_ (admin_properties->global_queue_length ()) + , max_queue_length_ (admin_properties->max_global_queue_length ()) + , order_policy_ (CosNotification::OrderPolicy, CosNotification::AnyOrder) + , discard_policy_ (CosNotification::DiscardPolicy, CosNotification::AnyOrder) + , max_events_per_consumer_ (CosNotification::MaxEventsPerConsumer) + , blocking_policy_ (TAO_Notify_Extensions::BlockingPolicy) + , global_not_full_ (admin_properties->global_queue_not_full()) + , local_not_full_ (global_queue_lock_) + , local_not_empty_ (global_queue_lock_) + , shutdown_ (false) { } @@ -47,31 +41,13 @@ TAO_Notify_Buffering_Strategy::~TAO_Notify_Buffering_Strategy () } void -TAO_Notify_Buffering_Strategy::update_qos_properties ( - const TAO_Notify_QoSProperties& qos_properties - ) +TAO_Notify_Buffering_Strategy::update_qos_properties + (const TAO_Notify_QoSProperties& qos_properties) { this->order_policy_.set (qos_properties); - - if (this->discard_policy_.set (qos_properties) != -1) - { - this->use_discarding_ = 1; - } - - TAO_Notify_Property_Time blocking_timeout (TAO_Notify_Extensions::BlockingPolicy); - - // if set to a valid time, init the blocking_time_ - if (blocking_timeout.set (qos_properties) != -1) - { - this->use_discarding_ = 0; - - this->blocking_time_ = -# if defined (ACE_CONFIG_WIN32_H) - ACE_Time_Value (static_cast<long> (blocking_timeout.value ())); -# else - ACE_Time_Value (blocking_timeout.value () / 1); -# endif /* ACE_CONFIG_WIN32_H */ - } + this->discard_policy_.set (qos_properties); + this->max_events_per_consumer_.set(qos_properties); + this->blocking_policy_.set (qos_properties); } void @@ -79,11 +55,16 @@ TAO_Notify_Buffering_Strategy::shutdown (void) { ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_); - this->shutdown_ = 1; + if (this->shutdown_) + { + return; + } - this->global_queue_not_full_condition_.broadcast (); - this->local_queue_not_full_condition_.broadcast (); - this->batch_size_reached_condition_.broadcast (); + this->shutdown_ = true; + + this->local_not_empty_.broadcast (); + this->global_not_full_.broadcast(); + this->local_not_full_.broadcast(); } int @@ -91,85 +72,65 @@ TAO_Notify_Buffering_Strategy::enqueue (TAO_Notify_Method_Request_Queueable& met { ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, -1); - // while either local or global max reached - while ((this->max_local_queue_length_ != 0 && - this->msg_queue_.message_count () == this->max_local_queue_length_) - || - (this->max_global_queue_length_.value () != 0 && - this->global_queue_length_ == this->max_global_queue_length_.value ())) - { - if (this->shutdown_ == 1) // if we're shutdown, don't play this silly game. + if (this->shutdown_) return -1; - if (this->use_discarding_ == 1) - { - if (this->global_queue_length_ == this->max_global_queue_length_.value () - && this->msg_queue_.message_count () == 0) // global max. reached but can't discard - { - // block. this is a hack because the real solution is - // to locate the appropriate queue and dequeue from it. - this->global_queue_not_full_condition_.wait (); - } - else // local max reached or, at global max but non-zero local count. - { - if (this->discard () == -1) - return -1; - - --this->global_queue_length_; - - // ACE_DEBUG ((LM_DEBUG, "Discarded from %x, global_queue_length = %d\n", this, this->global_queue_length_)); - - this->global_queue_not_full_condition_.signal (); - this->local_queue_not_full_condition_.signal (); - } - } - else // block + bool discarded_existing = false; + + bool local_overflow = this->max_events_per_consumer_.is_valid() && + this->msg_queue_.message_count () >= this->max_events_per_consumer_.value(); + + bool global_overflow = this->max_queue_length_.value () != 0 && + this->global_queue_length_ >= this->max_queue_length_.value (); + + while (local_overflow || global_overflow) { - if (this->msg_queue_.message_count () == this->max_local_queue_length_) // local maximum reached + if (blocking_policy_.is_valid()) { - if (this->blocking_time_ == ACE_Time_Value::zero) // wait forever if need be. + ACE_Time_Value timeout; + ORBSVCS_Time::TimeT_to_Time_Value(timeout, blocking_policy_.value()); + // Condition variables take an absolute time + timeout += ACE_OS::gettimeofday(); + if (local_overflow) { - this->local_queue_not_full_condition_.wait (); + local_not_full_.wait(&timeout); } - else // finite blocking time. + else { - ACE_Time_Value absolute = ACE_OS::gettimeofday () + this->blocking_time_; - - if (this->local_queue_not_full_condition_.wait (&absolute) == -1) // returns -1 on timeout - return -1; // Note message is discarded if it could not be enqueued in the given time. - } + global_not_full_.wait(&timeout); } - else // global max reached - { - if (this->blocking_time_ == ACE_Time_Value::zero) // wait forever if need be. + if (errno != ETIME) { - this->global_queue_not_full_condition_.wait (); + local_overflow = this->max_events_per_consumer_.is_valid() && + this->msg_queue_.message_count () >= this->max_events_per_consumer_.value(); + global_overflow = this->max_queue_length_.value () != 0 && + this->global_queue_length_ >= this->max_queue_length_.value (); + continue; + } } - else // finite blocking time. - { - ACE_Time_Value absolute = ACE_OS::gettimeofday () + blocking_time_; - if (this->global_queue_not_full_condition_.wait (&absolute) == -1) // returns -1 on timeout - return -1; + discarded_existing = this->discard(method_request); + if (discarded_existing) + { + --this->global_queue_length_; + local_not_full_.signal(); + global_not_full_.signal(); } + break; } - } // block - } // while + if (! (local_overflow || global_overflow) || discarded_existing) + { if (this->queue (method_request) == -1) { - ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " - "Panic! failed to enqueue event")); + ACE_DEBUG((LM_DEBUG, "Notify (%P|%t) - Panic! failed to enqueue event")); return -1; } ++this->global_queue_length_; - // ACE_DEBUG ((LM_DEBUG, "Inserted to %x, global_queue_length = %d\n", this, this->global_queue_length_)); - - if (this->msg_queue_.message_count () == this->batch_size_) - batch_size_reached_condition_.signal (); - + local_not_empty_.signal (); + } return this->msg_queue_.message_count (); } @@ -180,11 +141,14 @@ TAO_Notify_Buffering_Strategy::dequeue (TAO_Notify_Method_Request_Queueable* &me ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, -1); - while (this->msg_queue_.message_count () < this->batch_size_) // block + if ( this->shutdown_ ) + return -1; + + while (this->msg_queue_.message_count () == 0) { - this->batch_size_reached_condition_.wait (abstime); + this->local_not_empty_.wait (abstime); - if (this->shutdown_ == 1) // if we're shutdown, don't play this silly game. + if (this->shutdown_) return -1; if (errno == ETIME) @@ -194,17 +158,14 @@ TAO_Notify_Buffering_Strategy::dequeue (TAO_Notify_Method_Request_Queueable* &me if (this->msg_queue_.dequeue (mb) == -1) return -1; - method_request = dynamic_cast<TAO_Notify_Method_Request_Queueable*> (mb); + method_request = ACE_dynamic_cast (TAO_Notify_Method_Request_Queueable*, mb); if (method_request == 0) return -1; --this->global_queue_length_; - - // ACE_DEBUG ((LM_DEBUG, "Dequeued from %x, global_queue_length = %d\n", this, this->global_queue_length_)); - - this->global_queue_not_full_condition_.signal (); - this->local_queue_not_full_condition_.signal (); + local_not_full_.signal(); + global_not_full_.signal(); return 1; } @@ -212,57 +173,60 @@ TAO_Notify_Buffering_Strategy::dequeue (TAO_Notify_Method_Request_Queueable* &me int TAO_Notify_Buffering_Strategy::queue (TAO_Notify_Method_Request_Queueable& method_request) { - int result; + if ( this->shutdown_ ) + return -1; + + CORBA::Short order = this->order_policy_.value(); - // Queue according to order policy - if (this->order_policy_ == CosNotification::AnyOrder || - this->order_policy_ == CosNotification::FifoOrder) + if (! this->order_policy_.is_valid() || + order == CosNotification::AnyOrder || + order == CosNotification::FifoOrder) { if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " - "enqueue in fifo order\n")); - // Insert at the end of the queue. - result = this->msg_queue_.enqueue_tail (&method_request); + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - enqueue in fifo order\n")); + return this->msg_queue_.enqueue_tail (&method_request); } - else if (this->order_policy_ == CosNotification::PriorityOrder) + + if (order == CosNotification::PriorityOrder) { if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " - "enqueue in priority order\n")); - result = this->msg_queue_.enqueue_prio (&method_request); + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - enqueue in priority order\n")); + return this->msg_queue_.enqueue_prio (&method_request); } - else if (this->order_policy_ == CosNotification::DeadlineOrder) + + if (order == CosNotification::DeadlineOrder) { if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " - "enqueue in deadline order\n")); - result = this->msg_queue_.enqueue_deadline (&method_request); + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - enqueue in deadline order\n")); + return this->msg_queue_.enqueue_deadline (&method_request); } - else - { + if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - Invalid order policy\n")); - - result = -1; - } - - return result; + return this->msg_queue_.enqueue_tail (&method_request); } -int -TAO_Notify_Buffering_Strategy::discard (void) +bool +TAO_Notify_Buffering_Strategy::discard (TAO_Notify_Method_Request_Queueable& method_request) { - ACE_Message_Block *mb; - int result; - - if (this->discard_policy_ == CosNotification::AnyOrder || + if (this->shutdown_) + { + return false; + } + + ACE_Message_Block* mb = 0; + int result = -1; + if (this->discard_policy_.is_valid() == 0 || + this->discard_policy_ == CosNotification::AnyOrder || this->discard_policy_ == CosNotification::FifoOrder) { result = this->msg_queue_.dequeue_head (mb); } else if (this->discard_policy_ == CosNotification::LifoOrder) { - result = this->msg_queue_.dequeue_tail (mb); + // The most current message is NOT the newest one in the queue. It's + // the one we're about to add to the queue. + result = -1; } else if (this->discard_policy_ == CosNotification::DeadlineOrder) { @@ -271,17 +235,24 @@ TAO_Notify_Buffering_Strategy::discard (void) else if (this->discard_policy_ == CosNotification::PriorityOrder) { result = this->msg_queue_.dequeue_prio (mb); + if (mb->msg_priority() >= method_request.msg_priority()) + { + this->msg_queue_.enqueue_prio (mb); + result = -1; + } } else { if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " - "Invalid discard policy\n")); - result = -1; + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - Invalid discard policy\n")); + result = this->msg_queue_.dequeue_head (mb); } if (result != -1) + { ACE_Message_Block::release (mb); + return true; + } - return result; + return false; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h index a0205aec9e0..dce50b6cc63 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h @@ -43,14 +43,10 @@ typedef ACE_Message_Queue<ACE_NULL_SYNCH> TAO_Notify_Message_Queue; class TAO_Notify_Serv_Export TAO_Notify_Buffering_Strategy { public: - /// Constuctor TAO_Notify_Buffering_Strategy ( TAO_Notify_Message_Queue& msg_queue, - TAO_Notify_AdminProperties_var& admin_properties, - CORBA::Long batch_size - ); + TAO_Notify_AdminProperties::Ptr& admin_properties); - /// Destructor ~TAO_Notify_Buffering_Strategy (); /// Update state with the following QoS Properties: @@ -72,21 +68,13 @@ public: /// Shutdown void shutdown (void); - /// Set the new batch size. - void batch_size (CORBA::Long batch_size); +private: - /// Obtain our batch size - CORBA::Long batch_size (void); - - /// Set the max local queue length. - void max_local_queue_length (CORBA::Long length); - -protected: /// Apply the Order Policy and queue. return -1 on error. int queue (TAO_Notify_Method_Request_Queueable& method_request); /// Discard as per the Discard Policy. - int discard (void); + bool discard (TAO_Notify_Method_Request_Queueable& method_request); ///= Data Members @@ -94,22 +82,16 @@ protected: TAO_Notify_Message_Queue& msg_queue_; /// Reference to the properties per event channel. - TAO_Notify_AdminProperties_var admin_properties_; + TAO_Notify_AdminProperties::Ptr admin_properties_; /// The shared global lock used by all the queues. ACE_SYNCH_MUTEX& global_queue_lock_; - /// The shared Condition for global queue not full. - ACE_SYNCH_CONDITION& global_queue_not_full_condition_; - /// The global queue length - queue length accross all the queues. CORBA::Long& global_queue_length_; /// The maximum events that can be queued overall. - const TAO_Notify_Property_Long& max_global_queue_length_; - - /// The maximum queue length for the local queue. - CORBA::Long max_local_queue_length_; + const TAO_Notify_Property_Long& max_queue_length_; /// Order of events in internal buffers. TAO_Notify_Property_Short order_policy_; @@ -117,30 +99,20 @@ protected: /// Policy to discard when buffers are full. TAO_Notify_Property_Short discard_policy_; - /// Flag that we should use discarding(1) or blocking (0). - int use_discarding_; - - /// The blocking timeout will be used in place of discarding - /// This is a TAO specific extension. - ACE_Time_Value blocking_time_; // 0 means wait forever. + TAO_Notify_Property_Long max_events_per_consumer_; + TAO_Notify_Property_Time blocking_policy_; - /// Condition that the local queue is not full. - ACE_SYNCH_CONDITION local_queue_not_full_condition_; - /// The batch size that we want to monitor for dequeuing. - CORBA::Long batch_size_; + TAO_SYNCH_CONDITION& global_not_full_; + TAO_SYNCH_CONDITION local_not_full_; /// Condition that batch size reached. - ACE_SYNCH_CONDITION batch_size_reached_condition_; + TAO_SYNCH_CONDITION local_not_empty_; /// Flag to shutdown. - int shutdown_; + bool shutdown_; }; -#if defined (__ACE_INLINE__) -#include "Buffering_Strategy.inl" -#endif /* __ACE_INLINE__ */ - #include /**/ "ace/post.h" #endif /* TAO_Notify_BUFFERING_STRATEGY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl deleted file mode 100644 index d70f96d29ce..00000000000 --- a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl +++ /dev/null @@ -1,19 +0,0 @@ -// $Id$ - -ACE_INLINE void -TAO_Notify_Buffering_Strategy::batch_size (CORBA::Long batch_size) -{ - this->batch_size_ = batch_size; -} - -ACE_INLINE CORBA::Long -TAO_Notify_Buffering_Strategy::batch_size (void) -{ - return this->batch_size_; -} - -ACE_INLINE void -TAO_Notify_Buffering_Strategy::max_local_queue_length (CORBA::Long length) -{ - this->max_local_queue_length_ = length; -} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp index 06723e313b9..6edc4a75c39 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp @@ -205,8 +205,6 @@ TAO_Notify_Builder::build_event_channel_factory (PortableServer::POA_ptr poa ACE factory->create (ecf ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ecf_ret._retn ()); -// PortableServer::ServantBase_var servant_var (ecf); - ecf->init (poa ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ecf_ret._retn ()); ecf_ret = ecf->activate_self (ACE_ENV_SINGLE_ARG_PARAMETER); @@ -230,13 +228,11 @@ TAO_Notify_Builder::build_event_channel ( factory->create (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); -// PortableServer::ServantBase_var servant_var (ec); - ec->init (ecf, initial_qos, initial_admin ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); // insert ec in ec container. - ecf->ec_container_->insert (ec ACE_ENV_ARG_PARAMETER); + ecf->ec_container().insert (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ec_ret._retn ()); CORBA::Object_var obj = ec->activate (ec ACE_ENV_ARG_PARAMETER); @@ -266,7 +262,7 @@ TAO_Notify_Builder::build_event_channel ( ACE_CHECK_RETURN (0); // insert ec in ec container. - ecf->ec_container_->insert (ec ACE_ENV_ARG_PARAMETER); + ecf->ec_container().insert (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); ec->activate (ec, id ACE_ENV_ARG_PARAMETER); @@ -289,8 +285,6 @@ TAO_Notify_Builder::build_consumer_admin ( factory->create (ca ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ca_ret._retn ()); -// PortableServer::ServantBase_var servant_var (ca); - ca->init (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (ca_ret._retn ()); @@ -322,8 +316,6 @@ TAO_Notify_Builder::build_consumer_admin ( factory->create (ca ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); -// PortableServer::ServantBase_var servant_var (ca); - ca->init (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); @@ -347,8 +339,6 @@ TAO_Notify_Builder::build_supplier_admin (TAO_Notify_EventChannel* ec, CosNotify factory->create (sa ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (sa_ret._retn ()); -// PortableServer::ServantBase_var servant_var (sa); - sa->init (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (sa_ret._retn ()); @@ -363,7 +353,7 @@ TAO_Notify_Builder::build_supplier_admin (TAO_Notify_EventChannel* ec, CosNotify ACE_CHECK_RETURN (sa_ret._retn ()); // insert admin in SA container. - ec->sa_container_->insert (sa ACE_ENV_ARG_PARAMETER); + ec->sa_container().insert (sa ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (sa_ret._retn ()); return sa_ret._retn (); @@ -380,8 +370,6 @@ TAO_Notify_Builder::build_supplier_admin ( factory->create (sa ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); -// PortableServer::ServantBase_var servant_var (ca); - sa->init (ec ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); @@ -389,7 +377,7 @@ TAO_Notify_Builder::build_supplier_admin ( ACE_CHECK_RETURN (0); // insert admin in CA container. - ec->sa_container_->insert (sa ACE_ENV_ARG_PARAMETER); + ec->sa_container().insert (sa ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); return sa; @@ -571,12 +559,10 @@ TAO_Notify_Builder::apply_reactive_concurrency (TAO_Notify_Object& object ACE_EN CORBA::NO_MEMORY ()); ACE_CHECK; - worker_task->init (object.admin_properties_ ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - object.worker_task_own (worker_task); + object.set_worker_task (worker_task); - object.worker_task_->_decr_refcnt (); + worker_task->init (ACE_ENV_ARG_PARAMETER); + ACE_CHECK; } void @@ -589,12 +575,10 @@ TAO_Notify_Builder::apply_thread_pool_concurrency (TAO_Notify_Object& object, co CORBA::NO_MEMORY ()); ACE_CHECK; + object.set_worker_task (worker_task); + worker_task->init (tp_params, object.admin_properties_ ACE_ENV_ARG_PARAMETER); ACE_CHECK; - - object.worker_task_own (worker_task); - - object.worker_task_->_decr_refcnt (); } void diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp index 524bdb9821a..5ea6b8ae5db 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp @@ -10,7 +10,7 @@ ACE_RCSID (RT_Notify, TAO_Notify_Consumer, "$Id$") #include "Timer.h" #include "orbsvcs/Time_Utilities.h" -#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Bound_Ptr.h" #include "ace/Unbounded_Queue.h" #include "tao/debug.h" #include "Method_Request_Event.h" @@ -24,31 +24,25 @@ static const int DEFAULT_RETRY_TIMEOUT = 10;//120; // Note : This should be a co TAO_Notify_Consumer::TAO_Notify_Consumer (TAO_Notify_ProxySupplier* proxy) : proxy_ (proxy) - , pending_events_ (0) , is_suspended_ (0) , pacing_ (proxy->qos_properties_.pacing_interval ()) , max_batch_size_ (CosNotification::MaximumBatchSize, 0) , timer_id_ (-1) -// , buffering_strategy_ (0) , timer_ (0) { - ACE_NEW ( - this->pending_events_ , - TAO_Notify_Consumer::Request_Queue () - ); + Request_Queue* pending_events = 0; + ACE_NEW (pending_events, TAO_Notify_Consumer::Request_Queue ()); + this->pending_events_.reset( pending_events ); - this->timer_ = this->proxy ()->timer (); + this->timer_.reset( this->proxy ()->timer () ); } TAO_Notify_Consumer::~TAO_Notify_Consumer () { - delete this->pending_events_; -// delete this->buffering_strategy_; - if (this->timer_ == 0) + if (this->timer_.isSet()) { this->cancel_timer (); - this->timer_->_decr_refcnt (); - this->timer_ = 0; + this->timer_.reset (); } } @@ -62,19 +56,6 @@ void TAO_Notify_Consumer::qos_changed (const TAO_Notify_QoSProperties& qos_properties) { this->max_batch_size_ = qos_properties.maximum_batch_size (); - -/* -//@@ todo: consider buffering strategy - if (this->max_batch_size_.is_valid ()) - {// set the max batch size. - this->buffering_strategy_->batch_size (this->max_batch_size_.value ()); - } -*/ - - // Inform the buffering strategy of qos change. -/* - this->buffering_strategy_->update_qos_properties (qos_properties); -*/ } void @@ -90,8 +71,8 @@ TAO_Notify_Consumer::enqueue_request ( TAO_Notify_Method_Request_Event * request ACE_ENV_ARG_DECL) { - TAO_Notify_Event_var event_var; - request->event ()->queueable_copy (event_var ACE_ENV_ARG_PARAMETER); + TAO_Notify_Event::Ptr event_var ( + request->event ()->queueable_copy (ACE_ENV_SINGLE_ARG_PARAMETER) ); ACE_CHECK; TAO_Notify_Method_Request_Event_Queueable * queue_entry; ACE_NEW_THROW_EX (queue_entry, @@ -106,29 +87,29 @@ TAO_Notify_Consumer::enqueue_request ( request )); ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); - this->pending_events_->enqueue_tail (queue_entry); + this->pending_events().enqueue_tail (queue_entry); } bool TAO_Notify_Consumer::enqueue_if_necessary (TAO_Notify_Method_Request_Event * request ACE_ENV_ARG_DECL) { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock (), false); - if (! this->pending_events_->is_empty ()) + if (! this->pending_events().is_empty ()) { if (DEBUG_LEVEL > 3)ACE_DEBUG ( (LM_DEBUG, ACE_TEXT ("Consumer %d: enqueuing another event. %d\n"), static_cast<int> (this->proxy ()->id ()), request->sequence () )); - TAO_Notify_Event_var event_var; - request->event ()->queueable_copy (event_var ACE_ENV_ARG_PARAMETER); + TAO_Notify_Event::Ptr event_var ( + request->event ()->queueable_copy (ACE_ENV_SINGLE_ARG_PARAMETER) ); ACE_CHECK_RETURN (false); TAO_Notify_Method_Request_Event_Queueable * queue_entry; ACE_NEW_THROW_EX (queue_entry, TAO_Notify_Method_Request_Event_Queueable (*request, event_var), CORBA::NO_MEMORY ()); ACE_CHECK_RETURN (false); - this->pending_events_->enqueue_tail (queue_entry); + this->pending_events().enqueue_tail (queue_entry); this->schedule_timer (false); return true; } @@ -139,15 +120,15 @@ TAO_Notify_Consumer::enqueue_if_necessary (TAO_Notify_Method_Request_Event * req static_cast<int> (this->proxy ()->id ()), request->sequence () )); - TAO_Notify_Event_var event_var; - request->event ()->queueable_copy (event_var ACE_ENV_ARG_PARAMETER); + TAO_Notify_Event::Ptr event_var ( + request->event ()->queueable_copy (ACE_ENV_SINGLE_ARG_PARAMETER) ); ACE_CHECK_RETURN (false); TAO_Notify_Method_Request_Event_Queueable * queue_entry; ACE_NEW_THROW_EX (queue_entry, TAO_Notify_Method_Request_Event_Queueable (*request, event_var), CORBA::NO_MEMORY ()); ACE_CHECK_RETURN (false); - this->pending_events_->enqueue_tail (queue_entry); + this->pending_events().enqueue_tail (queue_entry); this->schedule_timer (false); return true; } @@ -159,8 +140,7 @@ TAO_Notify_Consumer::deliver (TAO_Notify_Method_Request_Event * request ACE_ENV_ { // Increment reference counts (safely) to prevent this object and its proxy // from being deleted while the push is in progress. - TAO_Notify_Refcountable_Guard_T<TAO_Notify_Proxy> proxy_guard (this->proxy ()); - TAO_Notify_Refcountable_Guard_T<TAO_Notify_Consumer> this_guard (this); + TAO_Notify_Proxy::Ptr proxy_guard (this->proxy ()); bool queued = enqueue_if_necessary (request ACE_ENV_ARG_PARAMETER); ACE_CHECK; if (!queued) @@ -369,18 +349,18 @@ TAO_Notify_Consumer::dispatch_pending (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) if (DEBUG_LEVEL > 5) ACE_DEBUG ( (LM_DEBUG, ACE_TEXT ("Consumer %d dispatching pending events. Queue size: %d\n"), static_cast<int> (this->proxy ()->id ()), - this->pending_events_->size () + this->pending_events().size () )); // lock ourselves in memory for the duration - TAO_Notify_Refcountable_Guard_T<TAO_Notify_Consumer> self_grd (this); + TAO_Notify_Consumer::Ptr self_grd (this); // dispatch events until: 1) the queue is empty; 2) the proxy shuts down, or 3) the dispatch fails ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); bool ok = true; - while (ok && !this->proxy_supplier ()->has_shutdown () && !this->pending_events_->is_empty ()) + while (ok && !this->proxy_supplier ()->has_shutdown () && !this->pending_events().is_empty ()) { - if (! dispatch_from_queue (*this->pending_events_, ace_mon)) + if (! dispatch_from_queue ( this->pending_events(), ace_mon)) { this->schedule_timer (true); ok = false; @@ -464,6 +444,12 @@ TAO_Notify_Consumer::dispatch_from_queue (Request_Queue & requests, ACE_Guard <T result = true; break; } + default: + { + ace_mon.acquire (); + result = false; + break; + } } } return result; @@ -484,7 +470,7 @@ TAO_Notify_Consumer::schedule_timer (bool is_error) return; } - ACE_ASSERT (this->timer_ != 0); + ACE_ASSERT (this->timer_.get() != 0); // If we're scheduling the timer due to an error then we want to // use the retry timeout, otherwise we'll assume that the pacing @@ -520,7 +506,7 @@ TAO_Notify_Consumer::schedule_timer (bool is_error) void TAO_Notify_Consumer::cancel_timer (void) { - if (this->timer_ != 0 && this->timer_id_ != -1) + if (this->timer_.isSet() && this->timer_id_ != -1) { if (DEBUG_LEVEL > 5) ACE_DEBUG ( (LM_DEBUG, ACE_TEXT ("Consumer %d canceling dispatch timer.\n"), @@ -535,7 +521,7 @@ TAO_Notify_Consumer::cancel_timer (void) int TAO_Notify_Consumer::handle_timeout (const ACE_Time_Value&, const void*) { - TAO_Notify_Refcountable_Guard_T<TAO_Notify_Consumer> grd (this); + TAO_Notify_Consumer::Ptr grd (this); this->timer_id_ = -1; // This must come first, because dispatch_pending may try to resched ACE_DECLARE_NEW_ENV; ACE_TRY @@ -554,11 +540,10 @@ TAO_Notify_Consumer::handle_timeout (const ACE_Time_Value&, const void*) void TAO_Notify_Consumer::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) { - if (this->timer_ == 0) + if (this->timer_.isSet ()) { this->cancel_timer (); - this->timer_->_decr_refcnt (); - this->timer_ = 0; + this->timer_.reset (); } } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.h b/TAO/orbsvcs/orbsvcs/Notify/Consumer.h index 1dea726c618..5f4e14af383 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Consumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.h @@ -25,6 +25,7 @@ #include "Peer.h" #include "Event.h" +#include "Timer.h" #include "ace/Event_Handler.h" class TAO_Notify_ProxySupplier; @@ -50,8 +51,6 @@ public: DISPATCH_DISCARD, // discard this message DISPATCH_FAIL}; // discard all messages and disconnect consumer - typedef ACE_Unbounded_Queue<TAO_Notify_Method_Request_Event_Queueable *> Request_Queue; - public: /// Constuctor TAO_Notify_Consumer (TAO_Notify_ProxySupplier* proxy); @@ -105,6 +104,8 @@ public: virtual void qos_changed (const TAO_Notify_QoSProperties& qos_properties); protected: + typedef ACE_Unbounded_Queue<TAO_Notify_Method_Request_Event_Queueable *> Request_Queue; + DispatchStatus dispatch_request (TAO_Notify_Method_Request_Event * request); /** @@ -151,12 +152,11 @@ protected: ///= Protected Data Members protected: + Request_Queue& pending_events(); + /// The Proxy that we associate with. TAO_Notify_ProxySupplier* proxy_; - /// Events pending to be delivered. - Request_Queue * pending_events_; - /// Suspended Flag. CORBA::Boolean is_suspended_; @@ -177,7 +177,12 @@ protected: // TAO_Notify_Batch_Buffering_Strategy* buffering_strategy_; // /// The Timer Manager that we use. - TAO_Notify_Timer* timer_; + TAO_Notify_Timer::Ptr timer_; + +private: + + /// Events pending to be delivered. + ACE_Auto_Ptr< Request_Queue > pending_events_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl index 5bbdbc22dff..56f30e36463 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl @@ -4,6 +4,14 @@ //#include "Method_Request.h" #include "Method_Request_Dispatch.h" +ACE_INLINE +TAO_Notify_Consumer::Request_Queue& +TAO_Notify_Consumer::pending_events() +{ + ACE_ASSERT( pending_events_.get() != 0 ); + return *pending_events_; +} + ACE_INLINE TAO_SYNCH_MUTEX* TAO_Notify_Consumer::proxy_lock (void) { diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp index 3c51bcf6f56..7bd0bf9c0df 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp @@ -262,7 +262,7 @@ TAO_Notify_ConsumerAdmin::push_suppliers (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_Proxy_Seq_Worker seq_worker; - return seq_worker.create (*this->proxy_container_ ACE_ENV_ARG_PARAMETER); + return seq_worker.create (this->proxy_container() ACE_ENV_ARG_PARAMETER); } CosNotifyChannelAdmin::ProxySupplier_ptr @@ -274,7 +274,7 @@ TAO_Notify_ConsumerAdmin::get_proxy_supplier (CosNotifyChannelAdmin::ProxyID pro { TAO_Notify_ProxySupplier_Find_Worker find_worker; - return find_worker.resolve (proxy_id, *this->proxy_container_ ACE_ENV_ARG_PARAMETER); + return find_worker.resolve (proxy_id, this->proxy_container() ACE_ENV_ARG_PARAMETER); } void TAO_Notify_ConsumerAdmin::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) @@ -318,7 +318,7 @@ TAO_Notify_ConsumerAdmin::subscription_change (const CosNotification::EventTypeS TAO_Notify_Subscription_Change_Worker worker (added, removed); - this->proxy_container_->collection()->for_each (&worker ACE_ENV_ARG_PARAMETER); + this->proxy_container().collection()->for_each (&worker ACE_ENV_ARG_PARAMETER); } this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); } @@ -470,7 +470,7 @@ TAO_Notify_ConsumerAdmin::find_proxy_supplier ( if (position < path_size) { TAO_Notify_ProxySupplier_Find_Worker find_worker; - TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], *this->proxy_container_ ACE_ENV_ARG_PARAMETER); + TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], this->proxy_container() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); result = dynamic_cast <TAO_Notify_ProxySupplier *> (proxy); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h index 9251ae44d8a..73e3c31d381 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h @@ -40,11 +40,12 @@ class TAO_Notify_Serv_Export TAO_Notify_ConsumerAdmin : public POA_NotifyExt::Co , public virtual TAO_Notify_Admin { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_ConsumerAdmin > Ptr; /// Constuctor TAO_Notify_ConsumerAdmin (void); /// Destructor - ~TAO_Notify_ConsumerAdmin (); + virtual ~TAO_Notify_ConsumerAdmin (); /// Init void init (TAO_Notify_EventChannel *ec ACE_ENV_ARG_DECL); @@ -53,8 +54,6 @@ public: virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); - /// Release this object. - virtual void release (void); virtual const char * get_admin_type_name () const; @@ -235,6 +234,10 @@ protected: CORBA::SystemException )); +private: + + /// Release this object. + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp index da6c7459da9..6a49c843814 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp @@ -16,19 +16,15 @@ ACE_RCSID (Notify, "$Id$") TAO_CosNotify_Service::TAO_CosNotify_Service (void) - : factory_ (0) - , builder_ (0) { } TAO_CosNotify_Service::~TAO_CosNotify_Service () { - delete this->factory_; - delete this->builder_; } int -TAO_CosNotify_Service::init (int argc, char *argv[]) +TAO_CosNotify_Service::init (int argc, ACE_TCHAR *argv[]) { ACE_Arg_Shifter arg_shifter (argc, argv); @@ -51,6 +47,8 @@ TAO_CosNotify_Service::init (int argc, char *argv[]) { // If Dispatching Threads are initalized, the option is implicit. arg_shifter.consume_arg (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) The -MTDispatching option has been deprecated, use -DispatchingThreads \n"))); } else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-DispatchingThreads")))) { @@ -61,6 +59,8 @@ TAO_CosNotify_Service::init (int argc, char *argv[]) { // If Source Threads are initalized, the option is implicit. arg_shifter.consume_arg (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) The -MTSourceEval option has been deprecated, use -SourceThreads \n"))); } else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-SourceThreads")))) { @@ -69,21 +69,33 @@ TAO_CosNotify_Service::init (int argc, char *argv[]) } else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-MTLookup")) == 0) { - // If Source Threads are initalized, the option is implicit. + // If Lookup Threads are initalized, the option is implicit. arg_shifter.consume_arg (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) The -MTLookup option has been deprecated, use -SourceThreads \n"))); } else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-LookupThreads")))) { + // Since this option is always either added to source_threads + // or ignored, we'll deprecate it in favor of that option. lookup_threads = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) The -LookupThreads option has been deprecated, use -SourceThreads \n"))); } else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-MTListenerEval")) == 0) { - // If Source Threads are initalized, the option is implicit. + // If Listener Threads are initalized, the option is implicit. arg_shifter.consume_arg (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) The -MTListenerEval option has been deprecated, use -DispatchingThreads \n"))); } else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-ListenerThreads")))) { + // Since this option is always added to dispatching_threads, we'll + // deprecate it in favor of that option. + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) The -ListenerThreads option has been deprecated, use -DispatchingThreads \n"))); listener_threads = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } @@ -109,6 +121,14 @@ TAO_CosNotify_Service::init (int argc, char *argv[]) arg_shifter.consume_arg (); TAO_Notify_PROPERTIES::instance()->allow_reconnect (true); } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) Ignoring unknown option for Notify Factory: %s\n"), + arg_shifter.get_current() + )); + arg_shifter.consume_arg (); + } } // Init the EC QoS @@ -172,7 +192,7 @@ TAO_CosNotify_Service::fini (void) } void -TAO_CosNotify_Service::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +TAO_CosNotify_Service::init_service (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { ACE_DEBUG ((LM_DEBUG, "Loading the Cos Notification Service...\n")); @@ -202,42 +222,47 @@ TAO_CosNotify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) properties->default_poa (default_poa.in ()); // Init the factory - this->init_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + this->factory_.reset (this->create_factory (ACE_ENV_SINGLE_ARG_PARAMETER)); + ACE_ASSERT( this->factory_.get() != 0 ); + TAO_Notify_PROPERTIES::instance()->factory (this->factory_.get()); ACE_CHECK; - this->init_builder (ACE_ENV_SINGLE_ARG_PARAMETER); + this->builder_.reset (this->create_builder (ACE_ENV_SINGLE_ARG_PARAMETER)); + ACE_ASSERT( this->builder_.get() != 0 ); + TAO_Notify_PROPERTIES::instance()->builder (this->builder_.get()); ACE_CHECK; } -void -TAO_CosNotify_Service::init_factory (ACE_ENV_SINGLE_ARG_DECL) +TAO_Notify_Factory* +TAO_CosNotify_Service::create_factory (ACE_ENV_SINGLE_ARG_DECL) { - this->factory_ = ACE_Dynamic_Service<TAO_Notify_Factory>::instance ("TAO_Notify_Factory"); - - if (this->factory_ == 0) - ACE_NEW_THROW_EX (this->factory_, + TAO_Notify_Factory* factory = ACE_Dynamic_Service<TAO_Notify_Factory>::instance ("TAO_Notify_Factory"); + if (factory == 0) + { + ACE_NEW_THROW_EX (factory, TAO_Notify_Default_Factory (), CORBA::NO_MEMORY ()); ACE_CHECK; - - TAO_Notify_PROPERTIES::instance()->factory (this->factory_); + } + return factory; } -void -TAO_CosNotify_Service::init_builder (ACE_ENV_SINGLE_ARG_DECL) +TAO_Notify_Builder* +TAO_CosNotify_Service::create_builder (ACE_ENV_SINGLE_ARG_DECL) { - ACE_NEW_THROW_EX (this->builder_, + TAO_Notify_Builder* builder = 0; + ACE_NEW_THROW_EX (builder, TAO_Notify_Builder (), CORBA::NO_MEMORY ()); ACE_CHECK; - TAO_Notify_PROPERTIES::instance()->builder (this->builder_); + return builder; } CosNotifyChannelAdmin::EventChannelFactory_ptr TAO_CosNotify_Service::create (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) { - return this->builder_->build_event_channel_factory (poa ACE_ENV_ARG_PARAMETER); + return this->builder().build_event_channel_factory (poa ACE_ENV_ARG_PARAMETER); } void @@ -246,6 +271,21 @@ TAO_CosNotify_Service::remove (TAO_Notify_EventChannelFactory* /*ecf*/ ACE_ENV_A // NOP. } +TAO_Notify_Factory& +TAO_CosNotify_Service::factory (void) +{ + ACE_ASSERT( this->factory_.get() != 0 ); + return *this->factory_; +} + +TAO_Notify_Builder& +TAO_CosNotify_Service::builder (void) +{ + ACE_ASSERT( this->builder_.get() != 0 ); + return *this->builder_; +} + + /*********************************************************************************************************************/ ACE_STATIC_SVC_DEFINE (TAO_Notify_Default_EMO_Factory_OLD, @@ -268,13 +308,3 @@ ACE_STATIC_SVC_DEFINE (TAO_CosNotify_Service, ACE_FACTORY_DEFINE (TAO_Notify_Serv, TAO_CosNotify_Service) /*********************************************************************************************************************/ - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class ACE_Dynamic_Service<TAO_Notify_Factory>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate ACE_Dynamic_Service<TAO_Notify_Factory> - -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h index d077b3b3c02..6cade3ddca9 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h +++ b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.h @@ -20,9 +20,9 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "Service.h" +#include "Builder.h" +#include "Factory.h" -class TAO_Notify_Factory; -class TAO_Notify_Builder; class TAO_Notify_Properties; class TAO_Notify_EventChannelFactory; @@ -41,12 +41,13 @@ public: /// Destructor virtual ~TAO_CosNotify_Service (); - /// = Service_Object virtual method overloads. - virtual int init (int argc, char *argv[]); - virtual int fini (void); + /// Init the service from configurator + virtual int init (int argc, ACE_TCHAR *argv[]); + + /// Init the service from driver + virtual void init_service (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); - /// Init - virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + virtual int fini (void); /// Create the Channel Factory. virtual CosNotifyChannelAdmin::EventChannelFactory_ptr create (PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL); @@ -58,20 +59,27 @@ protected: /// Init the data members virtual void init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); +private: + /// Create the Factory for Notify objects. - virtual void init_factory (ACE_ENV_SINGLE_ARG_DECL); + virtual TAO_Notify_Factory* create_factory (ACE_ENV_SINGLE_ARG_DECL); /// Create the Builder for Notify objects. - virtual void init_builder (ACE_ENV_SINGLE_ARG_DECL); + virtual TAO_Notify_Builder* create_builder (ACE_ENV_SINGLE_ARG_DECL); /// Set thread options on <qos>. void set_threads (CosNotification::QoSProperties &qos, int threads); + TAO_Notify_Factory& factory(); + + /// Service component for building NS participants. + TAO_Notify_Builder& builder(); + /// Service component for object factory operations. - TAO_Notify_Factory* factory_; + ACE_Auto_Ptr< TAO_Notify_Factory > factory_; /// Service component for building NS participants. - TAO_Notify_Builder* builder_; + ACE_Auto_Ptr< TAO_Notify_Builder > builder_; }; ACE_STATIC_SVC_DECLARE (TAO_CosNotify_Service) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp index dd8202f59c4..07c1acffaa7 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Default_Factory.cpp @@ -190,225 +190,3 @@ TAO_Notify_Default_Factory::create (TAO_Notify_SequenceProxyPushSupplier*& proxy ACE_FACTORY_DEFINE (TAO_Notify_Serv, TAO_Notify_Default_Factory) -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class TAO_Notify_ProxySupplier_T <POA_Event_Forwarder::StructuredProxyPushSupplier>; -template class TAO_Notify_Proxy_T <POA_Event_Forwarder::StructuredProxyPushSupplier>; -template class TAO_Notify_ProxySupplier_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier>; -template class TAO_Notify_Proxy_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier>; -template class TAO_Notify_ProxySupplier_T <POA_Event_Forwarder::ProxyPushSupplier>; -template class TAO_Notify_Proxy_T <POA_Event_Forwarder::ProxyPushSupplier>; -template class TAO_Notify_ProxySupplier_T <POA_CosEventChannelAdmin::ProxyPushSupplier>; -template class TAO_Notify_Proxy_T <POA_CosEventChannelAdmin::ProxyPushSupplier>; - -template class TAO_Notify_ProxyConsumer_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer>; -template class TAO_Notify_Proxy_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer>; -template class TAO_Notify_ProxyConsumer_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer>; -template class TAO_Notify_Proxy_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer>; -template class TAO_Notify_ProxyConsumer_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer>; -template class TAO_Notify_Proxy_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer>; -template class TAO_Notify_ProxyConsumer_T <POA_CosEventChannelAdmin::ProxyPushConsumer>; -template class TAO_Notify_Proxy_T <POA_CosEventChannelAdmin::ProxyPushConsumer>; - -template class TAO_ESF_Proxy_Collection<TAO_Notify_ProxyConsumer>; -template class TAO_ESF_Proxy_Collection<TAO_Notify_ProxySupplier>; -template class TAO_ESF_Proxy_Collection<TAO_Notify_EventChannel>; -template class TAO_ESF_Proxy_Collection<TAO_Notify_ConsumerAdmin>; -template class TAO_ESF_Proxy_Collection<TAO_Notify_SupplierAdmin>; -template class TAO_ESF_Proxy_Collection<TAO_Notify_Proxy>; -template class TAO_ESF_Proxy_Collection<TAO_Notify_Consumer>; -template class TAO_ESF_Proxy_Collection<TAO_Notify_Supplier>; -template class TAO_ESF_Proxy_Collection<TAO_Notify_Peer>; - -template class ACE_Unbounded_Set<int>; -//template class ACE_Unbounded_Set<TAO_Notify_EventType>; -//template class ACE_Unbounded_Set<TAO_Notify_ProxySupplier *>; - -template class ACE_Unbounded_Set_Const_Iterator<int>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *>; - -template class TAO_ESF_Copy_On_Write<TAO_Notify_Proxy, TAO_ESF_Proxy_List<TAO_Notify_Proxy>, ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write<TAO_Notify_Peer, TAO_ESF_Proxy_List<TAO_Notify_Peer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Peer *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write<TAO_Notify_Consumer, TAO_ESF_Proxy_List<TAO_Notify_Consumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write<TAO_Notify_Supplier, TAO_ESF_Proxy_List<TAO_Notify_Supplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write<TAO_Notify_EventChannel, TAO_ESF_Proxy_List<TAO_Notify_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write<TAO_Notify_ProxyConsumer, TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write<TAO_Notify_ProxySupplier, TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write<TAO_Notify_ConsumerAdmin, TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write<TAO_Notify_SupplierAdmin, TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin *>, ACE_SYNCH>; - -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>,ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier*>,TAO_SYNCH_MUTEX>; -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_EventChannel>,ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel*>,TAO_SYNCH_MUTEX>; -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>,ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin*>,TAO_SYNCH_MUTEX>; -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>,ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin*>,TAO_SYNCH_MUTEX>; -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>,ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer*>,TAO_SYNCH_MUTEX>; -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_Consumer>,ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer*>,TAO_SYNCH_MUTEX>; -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_Supplier>,ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier*>,TAO_SYNCH_MUTEX>; -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_Peer>,ACE_Unbounded_Set_Iterator<TAO_Notify_Peer*>,TAO_SYNCH_MUTEX>; -template class TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_Proxy>,ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy*>,TAO_SYNCH_MUTEX>; - - - -template class TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>; -template class TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>; -template class TAO_ESF_Proxy_List<TAO_Notify_Consumer>; -template class TAO_ESF_Proxy_List<TAO_Notify_Supplier>; -template class TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>; -template class TAO_ESF_Proxy_List<TAO_Notify_Proxy>; -template class TAO_ESF_Proxy_List<TAO_Notify_EventChannel>; -template class TAO_ESF_Proxy_List<TAO_Notify_Peer>; -template class TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>; - -template class ACE_Unbounded_Set<TAO_Notify_Peer *>; -template class ACE_Unbounded_Set<TAO_Notify_Supplier *>; -template class ACE_Unbounded_Set<TAO_Notify_Consumer *>; -template class ACE_Unbounded_Set<TAO_Notify_ProxyConsumer *>; -template class ACE_Unbounded_Set<TAO_Notify_ProxySupplier *>; -template class ACE_Unbounded_Set<TAO_Notify_ConsumerAdmin *>; -template class ACE_Unbounded_Set<TAO_Notify_SupplierAdmin *>; -template class ACE_Unbounded_Set<TAO_Notify_EventChannel *>; -template class ACE_Unbounded_Set<TAO_Notify_Proxy *>; -//template class ACE_Unbounded_Set<int>; - -template class ACE_Unbounded_Set_Iterator<TAO_Notify_Peer *>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier *>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer *>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer *>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier *>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin *>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin *>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel *>; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *>; -template class ACE_Unbounded_Set_Iterator<int>; - -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_Proxy>, ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_Peer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Peer *>, ACE_SYNCH>; - -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_Consumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier *>, ACE_SYNCH>; -template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_Supplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier *>, ACE_SYNCH>; - -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer *> >; -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_Supplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier *> >; -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin *> >; -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin *> >; -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel *> >; -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_Consumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer *> >; -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_Peer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Peer *> >; -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier *> >; -template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_Proxy>, ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *> >; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate TAO_Notify_ProxySupplier_T <POA_Event_Forwarder::StructuredProxyPushSupplier> -#pragma instantiate TAO_Notify_Proxy_T <POA_Event_Forwarder::StructuredProxyPushSupplier> -#pragma instantiate TAO_Notify_ProxySupplier_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier> -#pragma instantiate TAO_Notify_Proxy_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier> -#pragma instantiate TAO_Notify_ProxySupplier_T <POA_Event_Forwarder::ProxyPushSupplier> -#pragma instantiate TAO_Notify_Proxy_T <POA_Event_Forwarder::ProxyPushSupplier> -#pragma instantiate TAO_Notify_ProxySupplier_T <POA_CosEventChannelAdmin::ProxyPushSupplier> -#pragma instantiate TAO_Notify_Proxy_T <POA_CosEventChannelAdmin::ProxyPushSupplier> - -#pragma instantiate TAO_Notify_ProxyConsumer_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer> -#pragma instantiate TAO_Notify_Proxy_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer> -#pragma instantiate TAO_Notify_ProxyConsumer_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer> -#pragma instantiate TAO_Notify_Proxy_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer> -#pragma instantiate TAO_Notify_ProxyConsumer_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer> -#pragma instantiate TAO_Notify_Proxy_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer> -#pragma instantiate TAO_Notify_ProxyConsumer_T <POA_CosEventChannelAdmin::ProxyPushConsumer> -#pragma instantiate TAO_Notify_Proxy_T <POA_CosEventChannelAdmin::ProxyPushConsumer> - -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_ProxyConsumer> -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_ProxySupplier> -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_EventChannel> -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_ConsumerAdmin> -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_SupplierAdmin> -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_Proxy> -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_Consumer> -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_Supplier> -#pragma instantiate TAO_ESF_Proxy_Collection<TAO_Notify_Peer> - -#pragma instantiate ACE_Unbounded_Set<int> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_EventType> -//#pragma instantiate ACE_Unbounded_Set<TAO_Notify_ProxySupplier *> - -#pragma instantiate ACE_Unbounded_Set_Const_Iterator<int> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *> - -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_Proxy, TAO_ESF_Proxy_List<TAO_Notify_Proxy>, ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_Peer, TAO_ESF_Proxy_List<TAO_Notify_Peer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Peer *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_Consumer, TAO_ESF_Proxy_List<TAO_Notify_Consumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_Supplier, TAO_ESF_Proxy_List<TAO_Notify_Supplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_EventChannel, TAO_ESF_Proxy_List<TAO_Notify_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_ProxyConsumer, TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_ProxySupplier, TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_ConsumerAdmin, TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write<TAO_Notify_SupplierAdmin, TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin *>, ACE_SYNCH> - -#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>,ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier*>,ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_EventChannel>,ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel*>,ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>,ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin*>,ACE_SYNCH>#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>,ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin*>,ACE_SYNCH> -#pragma instantitae TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>,ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer*>,ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_Consumer>,ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer*>,ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_Supplier>,ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier*>,ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_Peer>,ACE_Unbounded_Set_Iterator<TAO_Notify_Peer*>,ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Read_Guard<TAO_ESF_Proxy_List<TAO_Notify_Proxy>,ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy*>,ACE_SYNCH> - - - -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin> -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin> -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_Consumer> -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_Supplier> -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer> -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_Proxy> -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_EventChannel> -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_Peer> -#pragma instantiate TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier> - -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_Peer *> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_Supplier *> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_Consumer *> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_ProxyConsumer *> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_ProxySupplier *> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_ConsumerAdmin *> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_SupplierAdmin *> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_EventChannel *> -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_Proxy *> - -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_Peer *> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier *> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer *> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer *> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier *> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin *> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin *> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel *> -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *> -#pragma instantiate ACE_Unbounded_Set_Iterator<int> - -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_Proxy>, ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_Peer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Peer *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_Consumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier *>, ACE_SYNCH> -#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_Notify_Supplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier *>, ACE_SYNCH> - -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxyConsumer *> > -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_Supplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_Supplier *> > -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_ConsumerAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_ConsumerAdmin *> > -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_SupplierAdmin>, ACE_Unbounded_Set_Iterator<TAO_Notify_SupplierAdmin *> > -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_Notify_EventChannel *> > -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_Consumer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Consumer *> > -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_Peer>, ACE_Unbounded_Set_Iterator<TAO_Notify_Peer *> > -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_Notify_ProxySupplier *> > -#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_Notify_Proxy>, ACE_Unbounded_Set_Iterator<TAO_Notify_Proxy *> > - -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Delivery_Request.cpp b/TAO/orbsvcs/orbsvcs/Notify/Delivery_Request.cpp index b78ff6882d2..6aab23ef245 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Delivery_Request.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Delivery_Request.cpp @@ -45,7 +45,7 @@ Delivery_Request::complete () // DO NOT INLINE THIS. It uses the Routing_Slip_Ptr which cannot be declared at // the time Delivery_Request.inl is compiled. -const TAO_Notify_Event_var & +const TAO_Notify_Event::Ptr & Delivery_Request::event () const { return this->routing_slip_->event (); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Delivery_Request.h b/TAO/orbsvcs/orbsvcs/Notify/Delivery_Request.h index 235a5a68f85..413e245eac3 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Delivery_Request.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Delivery_Request.h @@ -73,7 +73,7 @@ public: void complete (); /// \brief An accessor method for the event associated with the Routing Slip that owns this Delivery request. - const TAO_Notify_Event_var & event () const; + const TAO_Notify_Event::Ptr & event () const; /// \brief An accessor method for the routing slip that owns this request. const Routing_Slip_Ptr & routing_slip ()const; diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp index bab9645bb05..3aab442e6ff 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp @@ -327,6 +327,7 @@ TAO_Notify_ETCL_Filter::remove_all_constraints_i (ACE_ENV_SINGLE_ARG_DECL_NOT_US if (iter.next (entry) != 0) { delete entry->int_id_; + entry->int_id_ = 0; } } diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h index cfe0debaf2d..4d6ca6e90e6 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h @@ -44,7 +44,7 @@ public: TAO_Notify_ETCL_Filter (void); /// Destructor - ~TAO_Notify_ETCL_Filter (); + virtual ~TAO_Notify_ETCL_Filter (); protected: virtual char * constraint_grammar (ACE_ENV_SINGLE_ARG_DECL) diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h index 0ad5d79a760..38871fe90e7 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h @@ -45,7 +45,7 @@ public: TAO_Notify_ETCL_FilterFactory (void); /// Destructor - ~TAO_Notify_ETCL_FilterFactory (); + virtual ~TAO_Notify_ETCL_FilterFactory (); ///= TAO_Notify_FilterFactory methods. diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event.cpp index c2da7349d99..04e4e4ba7e8 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.cpp @@ -18,10 +18,11 @@ ACE_RCSID (Notify, #include "Structured/StructuredEvent.h" TAO_Notify_Event::TAO_Notify_Event (void) - :priority_ (CosNotification::Priority, CosNotification::DefaultPriority), - timeout_ (CosNotification::Timeout), - reliable_ (CosNotification::EventReliability, false), - event_on_heap_ (0) +: priority_ (CosNotification::Priority, CosNotification::DefaultPriority) +, timeout_ (CosNotification::Timeout) +, reliable_ (CosNotification::EventReliability, false) +, clone_ (0) +, is_on_heap_ (false) { // if (TAO_debug_level > 0) // ACE_DEBUG ((LM_DEBUG,"event:%x created\n", this )); @@ -78,20 +79,3 @@ TAO_Notify_Event::unmarshal (TAO_InputCDR & cdr) return result; } -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class ACE_Auto_Basic_Ptr<TAO_Notify_Event>; -template class TAO_Notify_Refcountable_Guard_T<TAO_Notify_Event>; -template class ACE_Unbounded_Queue<TAO_Notify_Event_var>; -template class ACE_Node<TAO_Notify_Event_var>; -template class ACE_Unbounded_Queue_Iterator<TAO_Notify_Event_var>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Notify_Event> -#pragma instantiate TAO_Notify_Refcountable_Guard_T<TAO_Notify_Event>; -#pragma instantiate ACE_Unbounded_Queue<TAO_Notify_Event_var> -#pragma instantiate ACE_Node<TAO_Notify_Event_var> -#pragma instantiate ACE_Unbounded_Queue_Iterator<TAO_Notify_Event_var> - -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.h b/TAO/orbsvcs/orbsvcs/Notify/Event.h index 3bc2296490f..5279cb927b4 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.h @@ -23,7 +23,6 @@ #include "ace/Copy_Disabled.h" #include "Refcountable.h" -#include "Refcountable_Guard_T.h" #include "orbsvcs/Event_ForwarderS.h" #include "orbsvcs/CosNotifyFilterC.h" @@ -35,42 +34,6 @@ class TAO_Notify_Consumer; class TAO_Notify_EventType; -class TAO_Notify_Event; - -typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_Event> TAO_Notify_Event_var_Base; - -/** - * @class TAO_Notify_Event_var - * - * @brief A Non-Copy version of the smart pointer that hides the constructors. - * - */ -class TAO_Notify_Event_var : public TAO_Notify_Event_var_Base -{ -public: - /// Default Constructor - TAO_Notify_Event_var (void); - -protected: - /// Constructor - TAO_Notify_Event_var (const TAO_Notify_Event* event); -}; - -/** - * @class TAO_Notify_Event - * - * @brief A smart pointer that allows construction from a TAO_Notify_Event - * - */ -class TAO_Notify_Event_Copy_var : public TAO_Notify_Event_var -{ -public: - /// Default Constructor - TAO_Notify_Event_Copy_var (void); - - /// Constructor - TAO_Notify_Event_Copy_var (const TAO_Notify_Event* event); -}; /** * @class TAO_Notify_Event @@ -83,6 +46,8 @@ class TAO_Notify_Serv_Export TAO_Notify_Event , private ACE_Copy_Disabled { public: + typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_Event> Ptr; + // Codes to distinguish marshaled events in persistent storage enum {MARSHAL_ANY=1,MARSHAL_STRUCTURED=2}; /// Constuctor @@ -91,8 +56,6 @@ public: /// Destructor virtual ~TAO_Notify_Event (); - virtual void release (void); - /// Translate Any to Structured static void translate (const CORBA::Any& any, CosNotification::StructuredEvent& notification); @@ -124,13 +87,13 @@ public: virtual void push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) const = 0; /// Return a pointer to a copy of this event on the heap - void queueable_copy (TAO_Notify_Event_var & ptr ACE_ENV_ARG_DECL) const; + TAO_Notify_Event* queueable_copy (ACE_ENV_SINGLE_ARG_DECL) const; /// marshal this event into a CDR buffer (for persistence) - virtual void marshal (TAO_OutputCDR & cdr) const = 0; + virtual void marshal (TAO_OutputCDR& cdr) const = 0; /// Unmarshal an event from a CDR. (for persistence) - static TAO_Notify_Event * unmarshal (TAO_InputCDR & cdr); + static TAO_Notify_Event* unmarshal (TAO_InputCDR & cdr); ///= Accessors /// Priority @@ -143,10 +106,6 @@ public: const TAO_Notify_Property_Boolean& reliable(void) const; protected: - - /// Return a pointer to a copy of this event on the heap - virtual TAO_Notify_Event * copy (ACE_ENV_SINGLE_ARG_DECL) const = 0; - /// = QoS properties /// Priority. @@ -158,7 +117,14 @@ protected: /// Reliability TAO_Notify_Property_Boolean reliable_; - TAO_Notify_Event * event_on_heap_; +private: + /// Return a pointer to a copy of this event on the heap + virtual TAO_Notify_Event* copy (ACE_ENV_SINGLE_ARG_DECL) const = 0; + + virtual void release (void); + + mutable Ptr clone_; + bool is_on_heap_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.inl b/TAO/orbsvcs/orbsvcs/Notify/Event.inl index b51106e8276..67df46a9242 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.inl @@ -18,46 +18,21 @@ TAO_Notify_Event::reliable (void) const return this->reliable_; } -/**********************************************************/ - -ACE_INLINE -TAO_Notify_Event_var::TAO_Notify_Event_var (void) - : TAO_Notify_Event_var_Base () -{ -} - -ACE_INLINE -TAO_Notify_Event_var::TAO_Notify_Event_var (const TAO_Notify_Event* event) - : TAO_Notify_Event_var_Base (const_cast <TAO_Notify_Event *>(event)) -{ -} - -/**********************************************************/ - ACE_INLINE -TAO_Notify_Event_Copy_var::TAO_Notify_Event_Copy_var (void) - : TAO_Notify_Event_var () +TAO_Notify_Event* +TAO_Notify_Event::queueable_copy (ACE_ENV_SINGLE_ARG_DECL) const { -} - -ACE_INLINE -TAO_Notify_Event_Copy_var::TAO_Notify_Event_Copy_var (const TAO_Notify_Event* event) - : TAO_Notify_Event_var (event) -{ -} - -ACE_INLINE -void //const TAO_Notify_Event * -TAO_Notify_Event::queueable_copy (TAO_Notify_Event_var & ptr ACE_ENV_ARG_DECL) const -{ - if (this->event_on_heap_ == 0) + if ( is_on_heap_ ) + { + return const_cast< TAO_Notify_Event* >( this ); + } + else if (this->clone_.get() == 0) { - TAO_Notify_Event * copied = - this->copy (ACE_ENV_SINGLE_ARG_PARAMETER); + TAO_Notify_Event* copied = this->copy (ACE_ENV_SINGLE_ARG_PARAMETER); + copied->is_on_heap_ = true; ACE_CHECK; - const_cast <TAO_Notify_Event *> (this)->event_on_heap_ = copied; - copied->event_on_heap_ = copied; + this->clone_.reset( copied ); } - ptr = TAO_Notify_Event_Copy_var (this->event_on_heap_); + return this->clone_.get(); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp index 7606224d57f..94cad727ea2 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp @@ -48,9 +48,6 @@ TAO_Notify_EventChannel::TAO_Notify_EventChannel (void) TAO_Notify_EventChannel::~TAO_Notify_EventChannel () { - delete this->event_manager_; // The EventChannel always owns the EventManager. - - this->ecf_->_decr_refcnt (); } void @@ -59,48 +56,52 @@ TAO_Notify_EventChannel::init (TAO_Notify_EventChannelFactory* ecf , const CosNotification::AdminProperties & initial_admin ACE_ENV_ARG_DECL) { + ACE_ASSERT (this->ca_container_.get() == 0); + // this-> on the following line confuses VC6 initialize (ecf ACE_ENV_ARG_PARAMETER); - this->ecf_ = ecf; - - this->ecf_->_incr_refcnt (); + this->ecf_.reset (ecf); // Init ca_container_ - ACE_NEW_THROW_EX (this->ca_container_, + TAO_Notify_ConsumerAdmin_Container* ca_container = 0; + ACE_NEW_THROW_EX (ca_container, TAO_Notify_ConsumerAdmin_Container (), CORBA::INTERNAL ()); ACE_CHECK; + this->ca_container_.reset (ca_container); - this->ca_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + this->ca_container().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; // Init ca_container_ - ACE_NEW_THROW_EX (this->sa_container_, + TAO_Notify_SupplierAdmin_Container* sa_container = 0; + ACE_NEW_THROW_EX (sa_container, TAO_Notify_SupplierAdmin_Container (), CORBA::INTERNAL ()); ACE_CHECK; + this->sa_container_.reset (sa_container); - this->sa_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + this->sa_container().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - TAO_Notify_AdminProperties* admin_properties = 0; - // Set the admin properties. + TAO_Notify_AdminProperties* admin_properties = 0; ACE_NEW_THROW_EX (admin_properties, TAO_Notify_AdminProperties (), CORBA::NO_MEMORY ()); ACE_CHECK; - - this->admin_properties_ = admin_properties; + this->set_admin_properties (admin_properties); // create the event manager. @@ use factory - ACE_NEW_THROW_EX (this->event_manager_, + TAO_Notify_Event_Manager* event_manager = 0; + ACE_NEW_THROW_EX (event_manager, TAO_Notify_Event_Manager (), CORBA::INTERNAL ()); ACE_CHECK; + this->set_event_manager (event_manager); - this->event_manager_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + this->event_manager().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; const CosNotification::QoSProperties &default_ec_qos = @@ -123,52 +124,55 @@ TAO_Notify_EventChannel::init (TAO_Notify_EventChannelFactory* ecf void -TAO_Notify_EventChannel::init (TAO_Notify::Topology_Parent * parent - ACE_ENV_ARG_DECL) +TAO_Notify_EventChannel::init (TAO_Notify::Topology_Parent* parent ACE_ENV_ARG_DECL) { + ACE_ASSERT (this->ecf_.get() == 0); // this-> on the following line confuses VC6 initialize (parent ACE_ENV_ARG_PARAMETER); - this->ecf_ = dynamic_cast <TAO_Notify_EventChannelFactory*>(parent); - ACE_ASSERT (this->ecf_ != 0); - - this->ecf_->_incr_refcnt (); + this->ecf_.reset (dynamic_cast <TAO_Notify_EventChannelFactory*>(parent)); + ACE_ASSERT (this->ecf_.get() !=0); // Init ca_container_ - ACE_NEW_THROW_EX (this->ca_container_, + TAO_Notify_ConsumerAdmin_Container* ca_container = 0; + ACE_NEW_THROW_EX (ca_container, TAO_Notify_ConsumerAdmin_Container (), CORBA::INTERNAL ()); ACE_CHECK; + this->ca_container_.reset (ca_container); - this->ca_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + this->ca_container().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; + TAO_Notify_SupplierAdmin_Container* sa_container = 0; // Init ca_container_ - ACE_NEW_THROW_EX (this->sa_container_, + ACE_NEW_THROW_EX (sa_container, TAO_Notify_SupplierAdmin_Container (), CORBA::INTERNAL ()); ACE_CHECK; + this->sa_container_.reset (sa_container); - this->sa_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + this->sa_container().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - TAO_Notify_AdminProperties* admin_properties = 0; // Set the admin properties. + TAO_Notify_AdminProperties* admin_properties = 0; ACE_NEW_THROW_EX (admin_properties, TAO_Notify_AdminProperties (), CORBA::NO_MEMORY ()); ACE_CHECK; - - this->admin_properties_ = admin_properties; + this->set_admin_properties (admin_properties); // create the event manager. @@ use factory - ACE_NEW_THROW_EX (this->event_manager_, + TAO_Notify_Event_Manager* event_manager = 0; + ACE_NEW_THROW_EX (event_manager, TAO_Notify_Event_Manager (), CORBA::INTERNAL ()); ACE_CHECK; + this->set_event_manager (event_manager); - this->event_manager_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + this->event_manager().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; const CosNotification::QoSProperties &default_ec_qos = @@ -205,16 +209,13 @@ TAO_Notify_EventChannel::shutdown (ACE_ENV_SINGLE_ARG_DECL) if (TAO_Notify_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) return 1; - this->ca_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + this->ca_container().shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (1); - this->sa_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + this->sa_container().shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (1); - delete this->ca_container_; - delete this->sa_container_; - - this->event_manager_->shutdown (); + this->event_manager().shutdown (); return 0; } @@ -237,13 +238,13 @@ TAO_Notify_EventChannel::destroy (ACE_ENV_SINGLE_ARG_DECL) void TAO_Notify_EventChannel::remove (TAO_Notify_ConsumerAdmin* consumer_admin ACE_ENV_ARG_DECL) { - this->ca_container_->remove (consumer_admin ACE_ENV_ARG_PARAMETER); + this->ca_container().remove (consumer_admin ACE_ENV_ARG_PARAMETER); } void TAO_Notify_EventChannel::remove (TAO_Notify_SupplierAdmin* supplier_admin ACE_ENV_ARG_DECL) { - this->sa_container_->remove (supplier_admin ACE_ENV_ARG_PARAMETER); + this->sa_container().remove (supplier_admin ACE_ENV_ARG_PARAMETER); } void @@ -290,7 +291,7 @@ TAO_Notify_EventChannel::default_consumer_admin (ACE_ENV_SINGLE_ARG_DECL) ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil()); // Wish there was a better way to do this! PortableServer::ServantBase * admin_servant = - this->poa_->reference_to_servant ( + this->poa()->reference_to_servant ( this->default_consumer_admin_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil()); @@ -320,7 +321,7 @@ TAO_Notify_EventChannel::default_supplier_admin (ACE_ENV_SINGLE_ARG_DECL) this->default_supplier_admin_ = this->new_for_suppliers (CosNotifyChannelAdmin::OR_OP, id ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CosNotifyChannelAdmin::SupplierAdmin::_nil()); PortableServer::ServantBase * admin_servant = - this->poa_->poa()->reference_to_servant ( + this->poa()->poa()->reference_to_servant ( this->default_supplier_admin_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); @@ -386,7 +387,7 @@ TAO_Notify_EventChannel::get_consumeradmin (CosNotifyChannelAdmin::AdminID id AC { TAO_Notify_ConsumerAdmin_Find_Worker find_worker; - return find_worker.resolve (id, *this->ca_container_ ACE_ENV_ARG_PARAMETER); + return find_worker.resolve (id, this->ca_container() ACE_ENV_ARG_PARAMETER); } CosNotifyChannelAdmin::SupplierAdmin_ptr @@ -398,7 +399,7 @@ TAO_Notify_EventChannel::get_supplieradmin (CosNotifyChannelAdmin::AdminID id AC { TAO_Notify_SupplierAdmin_Find_Worker find_worker; - return find_worker.resolve (id, *this->sa_container_ ACE_ENV_ARG_PARAMETER); + return find_worker.resolve (id, this->sa_container() ACE_ENV_ARG_PARAMETER); } CosNotifyChannelAdmin::AdminIDSeq* @@ -409,7 +410,7 @@ TAO_Notify_EventChannel::get_all_consumeradmins (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_ConsumerAdmin_Seq_Worker seq_worker; - return seq_worker.create (*this->ca_container_ ACE_ENV_ARG_PARAMETER); + return seq_worker.create (this->ca_container() ACE_ENV_ARG_PARAMETER); } CosNotifyChannelAdmin::AdminIDSeq* @@ -420,7 +421,7 @@ TAO_Notify_EventChannel::get_all_supplieradmins (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_SupplierAdmin_Seq_Worker seq_worker; - return seq_worker.create (*this->sa_container_ ACE_ENV_ARG_PARAMETER); + return seq_worker.create (this->sa_container() ACE_ENV_ARG_PARAMETER); } void @@ -430,7 +431,7 @@ TAO_Notify_EventChannel::set_admin (const CosNotification::AdminProperties & adm , CosNotification::UnsupportedAdmin )) { - this->admin_properties_->init (admin); + this->admin_properties().init (admin); } CosNotification::AdminProperties* @@ -445,7 +446,7 @@ TAO_Notify_EventChannel::get_admin (ACE_ENV_SINGLE_ARG_DECL) CosNotification::AdminProperties (), CORBA::NO_MEMORY ()); - this->admin_properties_->populate (properties); + this->admin_properties().populate (properties); return properties._retn (); } @@ -499,13 +500,11 @@ TAO_Notify_EventChannel::save_persistent (TAO_Notify::Topology_Saver& saver ACE_ TAO_Notify::Save_Persist_Worker<TAO_Notify_ConsumerAdmin> ca_wrk(saver, want_all_children); - ACE_ASSERT(this->ca_container_ != 0); - this->ca_container_->collection()->for_each(&ca_wrk ACE_ENV_ARG_PARAMETER); + this->ca_container().collection()->for_each(&ca_wrk ACE_ENV_ARG_PARAMETER); ACE_CHECK; TAO_Notify::Save_Persist_Worker<TAO_Notify_SupplierAdmin> sa_wrk(saver, want_all_children); - ACE_ASSERT(this->sa_container_ != 0); - this->sa_container_->collection()->for_each(&sa_wrk ACE_ENV_ARG_PARAMETER); + this->sa_container().collection()->for_each(&sa_wrk ACE_ENV_ARG_PARAMETER); ACE_CHECK; saver.end_object(this->id(), "channel" ACE_ENV_ARG_PARAMETER); @@ -537,21 +536,21 @@ void TAO_Notify_EventChannel::save_attrs(TAO_Notify::NVPList& attrs) { TAO_Notify_Object::save_attrs(attrs); - add_attr(attrs, this->admin_properties_->max_global_queue_length()); - add_attr(attrs, this->admin_properties_->max_consumers()); - add_attr(attrs, this->admin_properties_->max_suppliers()); - add_attr(attrs, this->admin_properties_->reject_new_events()); + add_attr(attrs, this->admin_properties().max_global_queue_length()); + add_attr(attrs, this->admin_properties().max_consumers()); + add_attr(attrs, this->admin_properties().max_suppliers()); + add_attr(attrs, this->admin_properties().reject_new_events()); } void TAO_Notify_EventChannel::load_attrs(const TAO_Notify::NVPList& attrs) { TAO_Notify_Object::load_attrs(attrs); - attrs.load(this->admin_properties_->max_global_queue_length()); - attrs.load(this->admin_properties_->max_consumers()); - attrs.load(this->admin_properties_->max_suppliers()); - attrs.load(this->admin_properties_->reject_new_events()); - this->admin_properties_->init(); + attrs.load(this->admin_properties().max_global_queue_length()); + attrs.load(this->admin_properties().max_consumers()); + attrs.load(this->admin_properties().max_suppliers()); + attrs.load(this->admin_properties().reject_new_events()); + this->admin_properties().init(); } TAO_Notify::Topology_Object * @@ -578,7 +577,7 @@ TAO_Notify_EventChannel::load_child (const ACE_CString &type, ca->load_attrs (attrs); if (ca->is_default ()) { - CORBA::Object_var caob = this->poa_->servant_to_reference (ca ACE_ENV_ARG_PARAMETER); + CORBA::Object_var caob = this->poa()->servant_to_reference (ca ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN(0); this->default_consumer_admin_ = CosNotifyChannelAdmin::ConsumerAdmin::_narrow ( @@ -603,7 +602,7 @@ TAO_Notify_EventChannel::load_child (const ACE_CString &type, sa->load_attrs (attrs); if (sa->is_default ()) { - CORBA::Object_var saob = this->poa_->servant_to_reference (sa ACE_ENV_ARG_PARAMETER); + CORBA::Object_var saob = this->poa()->servant_to_reference (sa ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN(0); this->default_supplier_admin_ = CosNotifyChannelAdmin::SupplierAdmin::_narrow ( @@ -622,7 +621,7 @@ TAO_Notify_EventChannel::find_proxy_consumer (TAO_Notify::IdVec & id_path, size_ if (position < path_size) { TAO_Notify_SupplierAdmin_Find_Worker find_worker; - TAO_Notify_SupplierAdmin * admin = find_worker.find (id_path[position], *this->sa_container_ ACE_ENV_ARG_PARAMETER); + TAO_Notify_SupplierAdmin * admin = find_worker.find (id_path[position], this->sa_container() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); ++position; if (admin != 0) @@ -643,7 +642,7 @@ TAO_Notify_EventChannel::find_proxy_supplier (TAO_Notify::IdVec & id_path, size_ if (position < path_size) { TAO_Notify_ConsumerAdmin_Find_Worker find_worker; - TAO_Notify_ConsumerAdmin * admin = find_worker.find (id_path[position], *this->ca_container_ ACE_ENV_ARG_PARAMETER); + TAO_Notify_ConsumerAdmin * admin = find_worker.find (id_path[position], this->ca_container() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); ++position; if (admin != 0) @@ -661,64 +660,25 @@ void TAO_Notify_EventChannel::reconnect (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify::Reconnect_Worker<TAO_Notify_ConsumerAdmin> ca_wrk; - ACE_ASSERT(this->ca_container_ != 0); - this->ca_container_->collection()->for_each(&ca_wrk ACE_ENV_ARG_PARAMETER); + this->ca_container().collection()->for_each(&ca_wrk ACE_ENV_ARG_PARAMETER); ACE_CHECK; TAO_Notify::Reconnect_Worker<TAO_Notify_SupplierAdmin> sa_wrk; - ACE_ASSERT(this->sa_container_ != 0); - this->sa_container_->collection()->for_each(&sa_wrk ACE_ENV_ARG_PARAMETER); + this->sa_container().collection()->for_each(&sa_wrk ACE_ENV_ARG_PARAMETER); ACE_CHECK; } -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class TAO_Notify_Find_Worker_T<TAO_Notify_ConsumerAdmin - , CosNotifyChannelAdmin::ConsumerAdmin - , CosNotifyChannelAdmin::ConsumerAdmin_ptr - , CosNotifyChannelAdmin::AdminNotFound>; -template class TAO_Notify_Find_Worker_T<TAO_Notify_SupplierAdmin - , CosNotifyChannelAdmin::SupplierAdmin - , CosNotifyChannelAdmin::SupplierAdmin_ptr - , CosNotifyChannelAdmin::AdminNotFound>; - -template class TAO_Notify_Seq_Worker_T<TAO_Notify_ConsumerAdmin>; -template class TAO_Notify_Seq_Worker_T<TAO_Notify_SupplierAdmin>; - -template class TAO_Notify_Container_T <TAO_Notify_ConsumerAdmin>; -template class TAO_Notify_Container_T <TAO_Notify_SupplierAdmin>; - -template class TAO_ESF_Shutdown_Proxy<TAO_Notify_ConsumerAdmin>; -template class TAO_ESF_Shutdown_Proxy<TAO_Notify_SupplierAdmin>; - -template class TAO_Notify::Save_Persist_Worker<TAO_Notify_ConsumerAdmin>; -template class TAO_Notify::Save_Persist_Worker<TAO_Notify_SupplierAdmin>; -template class TAO_Notify::Reconnect_Worker<TAO_Notify_ConsumerAdmin>; -template class TAO_Notify::Reconnect_Worker<TAO_Notify_SupplierAdmin>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate TAO_Notify_Find_Worker_T<TAO_Notify_ConsumerAdmin - , CosNotifyChannelAdmin::ConsumerAdmin - , CosNotifyChannelAdmin::ConsumerAdmin_ptr - , CosNotifyChannelAdmin::AdminNotFound> -#pragma instantiate TAO_Notify_Find_Worker_T<TAO_Notify_SupplierAdmin - , CosNotifyChannelAdmin::SupplierAdmin - , CosNotifyChannelAdmin::SupplierAdmin_ptr - , CosNotifyChannelAdmin::AdminNotFound> - -#pragma instantiate TAO_Notify_Seq_Worker_T<TAO_Notify_ConsumerAdmin> -#pragma instantiate TAO_Notify_Seq_Worker_T<TAO_Notify_SupplierAdmin> - -#pragma instantiate TAO_Notify_Container_T <TAO_Notify_ConsumerAdmin> -#pragma instantiate TAO_Notify_Container_T <TAO_Notify_SupplierAdmin> - -#pragma instantiate TAO_ESF_Shutdown_Proxy<TAO_Notify_ConsumerAdmin> -#pragma instantiate TAO_ESF_Shutdown_Proxy<TAO_Notify_SupplierAdmin> +TAO_Notify_EventChannel::TAO_Notify_ConsumerAdmin_Container& +TAO_Notify_EventChannel::ca_container() +{ + ACE_ASSERT( this->ca_container_.get() != 0 ); + return *ca_container_; +} -#pragma instantiate Save_Persist_Worker<TAO_Notify_ConsumerAdmin> -#pragma instantiate Save_Persist_Worker<TAO_Notify_SupplierAdmin> -#pragma instantiate TAO_Notify::Reconnect_Worker<TAO_Notify_ConsumerAdmin> -#pragma instantiate TAO_Notify::Reconnect_Worker<TAO_Notify_SupplierAdmin> +TAO_Notify_EventChannel::TAO_Notify_SupplierAdmin_Container& +TAO_Notify_EventChannel::sa_container() +{ + ACE_ASSERT( this->sa_container_.get() != 0 ); + return *sa_container_; +} -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h index 03269b6f39a..086282ad2a5 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h @@ -23,6 +23,8 @@ #include "orbsvcs/CosNotifyChannelAdminS.h" #include "Topology_Object.h" #include "Object.h" +#include "EventChannelFactory.h" + class TAO_Notify_ConsumerAdmin; class TAO_Notify_SupplierAdmin; @@ -49,6 +51,7 @@ class TAO_Notify_Serv_Export TAO_Notify_EventChannel friend class TAO_Notify_Builder; public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_EventChannel > Ptr; typedef CosNotifyChannelAdmin::ChannelIDSeq SEQ; typedef CosNotifyChannelAdmin::ChannelIDSeq_var SEQ_VAR; @@ -56,7 +59,7 @@ public: TAO_Notify_EventChannel (void); /// Destructor - ~TAO_Notify_EventChannel (); + virtual ~TAO_Notify_EventChannel (); /// Init void init (TAO_Notify_EventChannelFactory* ecf @@ -92,30 +95,20 @@ public: TAO_Notify_ProxyConsumer * find_proxy_consumer (TAO_Notify::IdVec & id_path, size_t position ACE_ENV_ARG_DECL); TAO_Notify_ProxySupplier * find_proxy_supplier (TAO_Notify::IdVec & id_path, size_t position ACE_ENV_ARG_DECL); - /// Release - virtual void release (void); /// Shutdown virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); virtual void load_attrs(const TAO_Notify::NVPList& attrs); - -protected: - virtual void save_attrs(TAO_Notify::NVPList& attrs); - -protected: +private: typedef TAO_Notify_Container_T <TAO_Notify_ConsumerAdmin> TAO_Notify_ConsumerAdmin_Container; typedef TAO_Notify_Container_T <TAO_Notify_SupplierAdmin> TAO_Notify_SupplierAdmin_Container; + virtual void save_attrs(TAO_Notify::NVPList& attrs); + /// = Data Members /// The parent object. - TAO_Notify_EventChannelFactory* ecf_; - - /// ConsumerAdmin Container. - TAO_Notify_ConsumerAdmin_Container *ca_container_; - - /// SupplierAdmin Container. - TAO_Notify_SupplierAdmin_Container *sa_container_; + TAO_Notify_EventChannelFactory::Ptr ecf_; TAO_SYNCH_MUTEX default_admin_mutex_; @@ -235,6 +228,19 @@ protected: ACE_THROW_SPEC (( CORBA::SystemException )); + +private: + TAO_Notify_ConsumerAdmin_Container& ca_container(); + TAO_Notify_SupplierAdmin_Container& sa_container(); + + /// ConsumerAdmin Container. + ACE_Auto_Ptr< TAO_Notify_ConsumerAdmin_Container > ca_container_; + + /// SupplierAdmin Container. + ACE_Auto_Ptr< TAO_Notify_SupplierAdmin_Container > sa_container_; + + /// Release + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp index 14d77a90707..7358af79f29 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp @@ -4,7 +4,6 @@ ACE_RCSID(Notify, TAO_Notify_EventChannelFactory, "$Id$") -#include "ace/Dynamic_Service.h" #include "Properties.h" #include "Factory.h" #include "Builder.h" @@ -14,12 +13,13 @@ ACE_RCSID(Notify, TAO_Notify_EventChannelFactory, "$Id$") #include "Reconnect_Worker_T.h" #include "Event_Persistence_Strategy.h" #include "Routing_Slip_Persistence_Manager.h" - #include "EventChannel.h" #include "Container_T.h" #include "Find_Worker_T.h" #include "Seq_Worker_T.h" +#include "ace/Dynamic_Service.h" + #include "tao/debug.h" //#define DEBUG_LEVEL 9 #ifndef DEBUG_LEVEL @@ -35,8 +35,7 @@ TAO_Notify_EventChannel_Find_Worker; typedef TAO_Notify_Seq_Worker_T<TAO_Notify_EventChannel> TAO_Notify_EventChannel_Seq_Worker; TAO_Notify_EventChannelFactory::TAO_Notify_EventChannelFactory (void) - : ec_container_ (0) - , topology_save_seq_ (0) + : topology_save_seq_ (0) , topology_factory_(0) , reconnect_registry_(*this) , loading_topology_ (false) @@ -59,8 +58,6 @@ TAO_Notify_EventChannelFactory::destroy (ACE_ENV_SINGLE_ARG_DECL) TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance(); - delete this->ec_container_; - // Reset references to CORBA objects. properties->orb (CORBA::ORB::_nil ()); properties->default_poa (PortableServer::POA::_nil ()); @@ -69,17 +66,21 @@ TAO_Notify_EventChannelFactory::destroy (ACE_ENV_SINGLE_ARG_DECL) void TAO_Notify_EventChannelFactory::init (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) { + ACE_ASSERT (this->ec_container_.get() == 0); + this->default_filter_factory_ = TAO_Notify_PROPERTIES::instance()->builder()->build_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; // Init ec_container_ - ACE_NEW_THROW_EX (this->ec_container_, + TAO_Notify_EventChannel_Container* ecc = 0; + ACE_NEW_THROW_EX (ecc, TAO_Notify_EventChannel_Container (), CORBA::INTERNAL ()); ACE_CHECK; + this->ec_container_.reset( ecc ); - this->ec_container_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + this->ec_container().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; TAO_Notify_POA_Helper* object_poa = 0; @@ -95,16 +96,7 @@ TAO_Notify_EventChannelFactory::init (PortableServer::POA_ptr poa ACE_ENV_ARG_DE object_poa->init (poa ACE_ENV_ARG_PARAMETER); ACE_CHECK; - // release auto_ref. - auto_object_poa.release (); - - this->object_poa_own (object_poa); - - // We are also activated in the same Object POA. - this->poa_ = this->object_poa_; - - // Make the Proxys acivate in this same POA. - this->proxy_poa_ = this->object_poa_; + this->adopt_poa (auto_object_poa.release ()); // Note topology factory is configured separately from the "builder" mediated // objects since it is independant of the "style" of Notification Service. @@ -140,7 +132,7 @@ TAO_Notify_EventChannelFactory::release (void) void TAO_Notify_EventChannelFactory::remove (TAO_Notify_EventChannel* event_channel ACE_ENV_ARG_DECL) { - this->ec_container_->remove (event_channel ACE_ENV_ARG_PARAMETER); + this->ec_container().remove (event_channel ACE_ENV_ARG_PARAMETER); ACE_CHECK; this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); } @@ -151,7 +143,7 @@ TAO_Notify_EventChannelFactory::shutdown (ACE_ENV_SINGLE_ARG_DECL) if (TAO_Notify_Object::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER) == 1) return 1; - this->ec_container_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + this->ec_container().shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (1); return 0; @@ -194,7 +186,7 @@ TAO_Notify_EventChannelFactory::get_all_channels (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_EventChannel_Seq_Worker seq_worker; - return seq_worker.create (*this->ec_container_ ACE_ENV_ARG_PARAMETER); + return seq_worker.create (this->ec_container() ACE_ENV_ARG_PARAMETER); } CosNotifyChannelAdmin::EventChannel_ptr @@ -206,7 +198,7 @@ TAO_Notify_EventChannelFactory::get_event_channel (CosNotifyChannelAdmin::Channe { TAO_Notify_EventChannel_Find_Worker find_worker; - return find_worker.resolve (id, *this->ec_container_ ACE_ENV_ARG_PARAMETER); + return find_worker.resolve (id, this->ec_container() ACE_ENV_ARG_PARAMETER); } void @@ -265,8 +257,7 @@ TAO_Notify_EventChannelFactory::save_persistent (TAO_Notify::Topology_Saver& sav TAO_Notify::Save_Persist_Worker<TAO_Notify_EventChannel> wrk(saver, want_all_children); - ACE_ASSERT(this->ec_container_ != 0); - this->ec_container_->collection()->for_each(&wrk ACE_ENV_ARG_PARAMETER); + this->ec_container().collection()->for_each(&wrk ACE_ENV_ARG_PARAMETER); ACE_CHECK; if (want_all_children || this->reconnect_registry_.is_changed ()) @@ -394,7 +385,7 @@ TAO_Notify_EventChannelFactory::reconnect (ACE_ENV_SINGLE_ARG_DECL) // Reconnect all children first TAO_Notify::Reconnect_Worker<TAO_Notify_EventChannel> wrk; - this->ec_container_->collection()->for_each(&wrk ACE_ENV_ARG_PARAMETER); + this->ec_container().collection()->for_each(&wrk ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Then send reconnection announcement to registered clients @@ -458,7 +449,7 @@ TAO_Notify_EventChannelFactory::find_proxy_consumer (TAO_Notify::IdVec & id_path // EventChannelFactory only: The first id is proably for the ECF itself // if so, silently consume it. - if (position < path_size && id_path[position] == this->id_) + if (position < path_size && id_path[position] == this->id()) { ++position; } @@ -466,7 +457,7 @@ TAO_Notify_EventChannelFactory::find_proxy_consumer (TAO_Notify::IdVec & id_path { TAO_Notify_EventChannel_Find_Worker find_worker; - TAO_Notify_EventChannel * ec = find_worker.find (id_path[position], *this->ec_container_ ACE_ENV_ARG_PARAMETER); + TAO_Notify_EventChannel * ec = find_worker.find (id_path[position], this->ec_container() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); ++position; if (ec != 0) @@ -487,14 +478,14 @@ TAO_Notify_EventChannelFactory::find_proxy_supplier (TAO_Notify::IdVec & id_path // EventChannelFactory only: The first id is proably for the ECF itself // if so, silently consume it. - if (position < path_size && id_path[position] == this->id_) + if (position < path_size && id_path[position] == this->id()) { ++position; } if (position < path_size) { TAO_Notify_EventChannel_Find_Worker find_worker; - TAO_Notify_EventChannel * ec = find_worker.find (id_path[position], *this->ec_container_ ACE_ENV_ARG_PARAMETER); + TAO_Notify_EventChannel * ec = find_worker.find (id_path[position], this->ec_container() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); ++position; if (ec != 0) @@ -539,29 +530,10 @@ TAO_Notify_EventChannelFactory::get_id () const return id(); } +TAO_Notify_EventChannelFactory::TAO_Notify_EventChannel_Container& +TAO_Notify_EventChannelFactory::ec_container() +{ + ACE_ASSERT( this->ec_container_.get() != 0 ); + return *ec_container_; +} -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class TAO_Notify_Find_Worker_T<TAO_Notify_EventChannel - , CosNotifyChannelAdmin::EventChannel - , CosNotifyChannelAdmin::EventChannel_ptr - , CosNotifyChannelAdmin::ChannelNotFound>; -template class TAO_Notify_Seq_Worker_T<TAO_Notify_EventChannel>; - -template class TAO_Notify_Container_T <TAO_Notify_EventChannel>; - -template class TAO_ESF_Shutdown_Proxy<TAO_Notify_EventChannel>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate TAO_Notify_Find_Worker_T<TAO_Notify_EventChannel - , CosNotifyChannelAdmin::EventChannel - , CosNotifyChannelAdmin::EventChannel_ptr - , CosNotifyChannelAdmin::ChannelNotFound> -#pragma instantiate TAO_Notify_Seq_Worker_T<TAO_Notify_EventChannel> - - -#pragma instantiate TAO_Notify_Container_T <TAO_Notify_EventChannel> - -#pragma instantiate TAO_ESF_Shutdown_Proxy<TAO_Notify_EventChannel>; - -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h index 04b336059d1..d2eabf13760 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h @@ -20,13 +20,14 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "orbsvcs/CosNotifyChannelAdminS.h" -#include "orbsvcs/NotifyExtS.h" #include "Topology_Object.h" #include "Topology_Factory.h" #include "Reconnection_Registry.h" #include "Routing_Slip.h" +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "orbsvcs/NotifyExtS.h" + class TAO_Notify_EventChannel; template <class TYPE> class TAO_Notify_Container_T; @@ -50,6 +51,8 @@ class TAO_Notify_Serv_Export TAO_Notify_EventChannelFactory typedef ACE_Unbounded_Set <TAO_Notify::Routing_Slip_Ptr> Routing_Slip_Set; public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_EventChannelFactory > Ptr; + /// Constuctor TAO_Notify_EventChannelFactory (void); @@ -63,9 +66,6 @@ public: virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); - /// Release this object. - virtual void release (void); - /// Remove <channel> from the <ec_container_> void remove (TAO_Notify_EventChannel* channel ACE_ENV_ARG_DECL); @@ -115,13 +115,9 @@ public: virtual TAO_Notify_Object::ID get_id () const; - protected: - typedef TAO_Notify_Container_T<TAO_Notify_EventChannel> - TAO_Notify_EventChannel_Container; + private: /// = Data Members - /// Container for Event Channels. - TAO_Notify_EventChannel_Container *ec_container_; /// The default filter factory. CosNotifyFilter::FilterFactory_var default_filter_factory_; @@ -174,6 +170,13 @@ public: CosNotifyChannelAdmin::ChannelNotFound)); private: + typedef TAO_Notify_Container_T<TAO_Notify_EventChannel> TAO_Notify_EventChannel_Container; + + TAO_Notify_EventChannel_Container& ec_container(); + + /// Container for Event Channels. + ACE_Auto_Ptr< TAO_Notify_EventChannel_Container > ec_container_; + TAO_SYNCH_MUTEX topology_save_lock_; CosNotifyChannelAdmin::EventChannelFactory_var channel_factory_; @@ -186,6 +189,9 @@ private: Routing_Slip_Set routing_slip_restart_set_; + /// Release this object. + virtual void release (void); + }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h index 1a80b261ea1..1628fcada2b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h @@ -74,8 +74,10 @@ public: virtual void save_persistent (TAO_Notify::Topology_Saver& saver ACE_ENV_ARG_DECL); virtual TAO_Notify::Topology_Object* load_child (const ACE_CString &type, CORBA::Long id, const TAO_Notify::NVPList& attrs ACE_ENV_ARG_DECL); - virtual void release (void); +private: + + virtual void release (void); }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp index ef8c778aa9d..cbc9d06f9a9 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp @@ -15,7 +15,6 @@ ACE_RCSID(Notify, TAO_Notify_Event_Manager, "$Id$") #include "Supplier_Map.h" TAO_Notify_Event_Manager::TAO_Notify_Event_Manager (void) - :consumer_map_ (0), supplier_map_ (0) { } @@ -24,28 +23,36 @@ TAO_Notify_Event_Manager::~TAO_Notify_Event_Manager () if (TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, "destroying consumer/supplier map count = %d/%d, \n", - this->consumer_map_->proxy_count (), this->supplier_map_->proxy_count ())); + this->consumer_map().proxy_count (), this->supplier_map().proxy_count ())); } +} - delete this->consumer_map_; - delete this->supplier_map_; +void TAO_Notify_Event_Manager::release() +{ + delete this; } void TAO_Notify_Event_Manager::init (ACE_ENV_SINGLE_ARG_DECL) { - ACE_NEW_THROW_EX (this->consumer_map_, + ACE_ASSERT (this->consumer_map_.get() == 0); + + TAO_Notify_Consumer_Map* consumer_map = 0; + ACE_NEW_THROW_EX (consumer_map, TAO_Notify_Consumer_Map (), CORBA::NO_MEMORY ()); ACE_CHECK; + this->consumer_map_.reset( consumer_map ); - ACE_NEW_THROW_EX (this->supplier_map_, - TAO_Notify_Supplier_Map (), - CORBA::NO_MEMORY ()); + this->consumer_map().init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - this->consumer_map_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + TAO_Notify_Supplier_Map* supplier_map = 0; + ACE_NEW_THROW_EX (supplier_map, + TAO_Notify_Supplier_Map (), + CORBA::NO_MEMORY ()); ACE_CHECK; + this->supplier_map_.reset( supplier_map ); this->supplier_map_->init (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; @@ -59,7 +66,7 @@ TAO_Notify_Event_Manager::shutdown (void) void TAO_Notify_Event_Manager::connect (TAO_Notify_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL) { - this->consumer_map_->connect (proxy_supplier ACE_ENV_ARG_PARAMETER); + this->consumer_map().connect (proxy_supplier ACE_ENV_ARG_PARAMETER); // Inform about offered types. TAO_Notify_EventTypeSeq removed; @@ -69,13 +76,13 @@ TAO_Notify_Event_Manager::connect (TAO_Notify_ProxySupplier* proxy_supplier ACE_ void TAO_Notify_Event_Manager::disconnect (TAO_Notify_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL) { - this->consumer_map_->disconnect (proxy_supplier ACE_ENV_ARG_PARAMETER); + this->consumer_map().disconnect (proxy_supplier ACE_ENV_ARG_PARAMETER); } void TAO_Notify_Event_Manager::connect (TAO_Notify_ProxyConsumer* proxy_consumer ACE_ENV_ARG_DECL) { - this->supplier_map_->connect (proxy_consumer ACE_ENV_ARG_PARAMETER); + this->supplier_map().connect (proxy_consumer ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Inform about subscription types. TAO_Notify_EventTypeSeq removed; @@ -85,7 +92,7 @@ TAO_Notify_Event_Manager::connect (TAO_Notify_ProxyConsumer* proxy_consumer ACE_ void TAO_Notify_Event_Manager::disconnect (TAO_Notify_ProxyConsumer* proxy_consumer ACE_ENV_ARG_DECL) { - this->supplier_map_->disconnect (proxy_consumer ACE_ENV_ARG_PARAMETER); + this->supplier_map().disconnect (proxy_consumer ACE_ENV_ARG_PARAMETER); } void @@ -99,7 +106,7 @@ TAO_Notify_Event_Manager::offer_change (TAO_Notify_ProxyConsumer* proxy_consumer this->un_publish (proxy_consumer, removed, last_removed ACE_ENV_ARG_PARAMETER); ACE_CHECK; - TAO_Notify_Consumer_Map::ENTRY::COLLECTION* updates_collection = this->consumer_map_->updates_collection (); + TAO_Notify_Consumer_Map::ENTRY::COLLECTION* updates_collection = this->consumer_map().updates_collection (); TAO_Notify_ProxySupplier_Update_Worker worker (new_added, last_removed); @@ -115,7 +122,7 @@ TAO_Notify_Event_Manager::subscription_change (TAO_Notify_ProxySupplier* proxy_s this->subscribe (proxy_supplier, added, new_added ACE_ENV_ARG_PARAMETER); this->un_subscribe (proxy_supplier, removed, last_removed ACE_ENV_ARG_PARAMETER); - TAO_Notify_Supplier_Map::ENTRY::COLLECTION* updates_collection = this->supplier_map_->updates_collection (); + TAO_Notify_Supplier_Map::ENTRY::COLLECTION* updates_collection = this->supplier_map().updates_collection (); TAO_Notify_ProxyConsumer_Update_Worker worker (new_added, last_removed); @@ -132,7 +139,7 @@ TAO_Notify_Event_Manager::subscribe (TAO_Notify_ProxySupplier* proxy_supplier, c for (iter.first (); iter.next (event_type) != 0; iter.advance ()) { - int result = consumer_map_->insert (proxy_supplier, *event_type ACE_ENV_ARG_PARAMETER); + int result = this->consumer_map().insert (proxy_supplier, *event_type ACE_ENV_ARG_PARAMETER); ACE_CHECK; if (result == 1) @@ -149,7 +156,7 @@ TAO_Notify_Event_Manager::un_subscribe (TAO_Notify_ProxySupplier* proxy_supplier for (iter.first (); iter.next (event_type) != 0; iter.advance ()) { - int result = consumer_map_->remove (proxy_supplier, *event_type ACE_ENV_ARG_PARAMETER); + int result = this->consumer_map().remove (proxy_supplier, *event_type ACE_ENV_ARG_PARAMETER); ACE_CHECK; if (result == 1) @@ -166,7 +173,7 @@ TAO_Notify_Event_Manager::publish (TAO_Notify_ProxyConsumer* proxy_consumer, con for (iter.first (); iter.next (event_type) != 0; iter.advance ()) { - int result = supplier_map_->insert (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); + int result = supplier_map().insert (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); ACE_CHECK; if (result == 1) @@ -183,7 +190,7 @@ TAO_Notify_Event_Manager::un_publish (TAO_Notify_ProxyConsumer* proxy_consumer, for (iter.first (); iter.next (event_type) != 0; iter.advance ()) { - int result = supplier_map_->remove (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); + int result = supplier_map().remove (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); ACE_CHECK; if (result == 1) @@ -191,133 +198,3 @@ TAO_Notify_Event_Manager::un_publish (TAO_Notify_ProxyConsumer* proxy_consumer, } } -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class TAO_Notify_Event_Map_T<TAO_Notify_ProxySupplier, TAO_SYNCH_RW_MUTEX>; -template class TAO_Notify_Event_Map_T<TAO_Notify_ProxyConsumer, TAO_SYNCH_RW_MUTEX>; - -template class ACE_Hash<TAO_Notify_EventType>; -template class ACE_Equal_To<TAO_Notify_EventType>; - -template class TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer>; -template class TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier>; - -template class ACE_Hash_Map_Manager_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Manager_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Manager<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Null_Mutex>; -template class ACE_Hash_Map_Manager<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Null_Mutex>; -template class ACE_Hash_Map_Manager<ACE_CString, CORBA::Any, ACE_Null_Mutex>; - -template class ACE_Unbounded_Set<TAO_Notify_EventType>; -template class ACE_Unbounded_Set_Const_Iterator<TAO_Notify_EventType>; -template class ACE_Unbounded_Queue<ACE_Refcounted_Auto_Ptr<TAO_Notify_Event, TAO_SYNCH_MUTEX> >; -template class ACE_Unbounded_Set_Iterator<TAO_Notify_EventType>; - -template class TAO_ESF_Worker<TAO_Notify_ProxySupplier>; -template class TAO_ESF_Worker<TAO_Notify_ProxyConsumer>; -template class TAO_ESF_Worker<TAO_Notify_Proxy>; -template class TAO_ESF_Worker<TAO_Notify_Consumer>; -template class TAO_ESF_Worker<TAO_Notify_Peer>; -template class TAO_ESF_Worker<TAO_Notify_SupplierAdmin>; -template class TAO_ESF_Worker<TAO_Notify_ConsumerAdmin>; -template class TAO_ESF_Worker<TAO_Notify_EventChannel>; - -template class ACE_Refcounted_Auto_Ptr<TAO_Notify_Event, TAO_SYNCH_MUTEX>; -template class ACE_Unbounded_Queue_Iterator<ACE_Refcounted_Auto_Ptr<TAO_Notify_Event, TAO_SYNCH_MUTEX> >; - -template class ACE_Node<ACE_Refcounted_Auto_Ptr<TAO_Notify_Event, TAO_SYNCH_MUTEX > >; -template class ACE_Node<TAO_Notify_Supplier *>; -template class ACE_Node<TAO_Notify_SupplierAdmin *>; -template class ACE_Node<TAO_Notify_ConsumerAdmin *>; -template class ACE_Node<TAO_Notify_EventChannel *>; -template class ACE_Node<TAO_Notify_ProxyConsumer *>; -template class ACE_Node<TAO_Notify_EventType>; -template class ACE_Node<TAO_Notify_Peer *>; -template class ACE_Node<TAO_Notify_ProxySupplier *>; -template class ACE_Node<TAO_Notify_Proxy *>; -template class ACE_Node<TAO_Notify_Consumer *>; - -template class ACE_Hash_Map_Entry<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *>; -template class ACE_Hash_Map_Entry<ACE_CString, CORBA::Any>; -template class ACE_Hash_Map_Entry<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *>; - -template class ACE_Hash_Map_Iterator_Base_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex>; - -template class ACE_Hash_Map_Iterator_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex>; - -template class ACE_Hash_Map_Reverse_Iterator_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex>; - -template class ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex>; - -template class ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate TAO_Notify_Event_Map_T<TAO_Notify_ProxySupplier, TAO_SYNCH_RW_MUTEX> -#pragma instantiate TAO_Notify_Event_Map_T<TAO_Notify_ProxyConsumer, TAO_SYNCH_RW_MUTEX> - -#pragma instantiate ACE_Hash<TAO_Notify_EventType> -#pragma instantiate ACE_Equal_To<TAO_Notify_EventType> - -#pragma instantiate TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> -#pragma instantiate TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> - -#pragma instantiate ACE_Hash_Map_Manager_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Manager_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Manager<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Manager<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Manager<ACE_CString, CORBA::Any, ACE_Null_Mutex> - -#pragma instantiate ACE_Unbounded_Set<TAO_Notify_EventType> -#pragma instantiate ACE_Unbounded_Set_Const_Iterator<TAO_Notify_EventType> -#pragma instantiate ACE_Unbounded_Queue<ACE_Refcounted_Auto_Ptr<TAO_Notify_Event, TAO_SYNCH_MUTEX> > -#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_Notify_EventType> - -#pragma instantiate TAO_ESF_Worker<TAO_Notify_ProxySupplier> -#pragma instantiate TAO_ESF_Worker<TAO_Notify_ProxyConsumer> -#pragma instantiate TAO_ESF_Worker<TAO_Notify_Proxy> -#pragma instantiate TAO_ESF_Worker<TAO_Notify_Consumer> -#pragma instantiate TAO_ESF_Worker<TAO_Notify_Peer> -#pragma instantiate TAO_ESF_Worker<TAO_Notify_ConsumerAdmin> -#pragma instantiate TAO_ESF_Worker<TAO_Notify_SupplierAdmin> -#pragma instantiate TAO_ESF_Worker<TAO_Notify_EventChannel> - -#pragma instantiate ACE_Refcounted_Auto_Ptr<TAO_Notify_Event, TAO_SYNCH_MUTEX> -#pragma instantiate ACE_Unbounded_Queue_Iterator<ACE_Refcounted_Auto_Ptr<TAO_Notify_Event, TAO_SYNCH_MUTEX> > - -#pragma instantiate ACE_Node<ACE_Refcounted_Auto_Ptr<TAO_Notify_Event, TAO_SYNCH_MUTEX > > -#pragma instantiate ACE_Node<TAO_Notify_Supplier *> -#pragma instantiate ACE_Node<TAO_Notify_SupplierAdmin *> -#pragma instantiate ACE_Node<TAO_Notify_ConsumerAdmin *> -#pragma instantiate ACE_Node<TAO_Notify_EventChannel *> -#pragma instantiate ACE_Node<TAO_Notify_ProxyConsumer *> -#pragma instantiate ACE_Node<TAO_Notify_EventType> -#pragma instantiate ACE_Node<TAO_Notify_Peer *> -#pragma instantiate ACE_Node<TAO_Notify_ProxySupplier *> -#pragma instantiate ACE_Node<TAO_Notify_Proxy *> -#pragma instantiate ACE_Node<TAO_Notify_Consumer *> - -#pragma instantiate ACE_Hash_Map_Entry<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *> -#pragma instantiate ACE_Hash_Map_Entry<ACE_CString, CORBA::Any> -#pragma instantiate ACE_Hash_Map_Entry<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *> - -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex> - -#pragma instantiate ACE_Hash_Map_Iterator_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex> - -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxySupplier> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<TAO_Notify_EventType, TAO_Notify_Event_Map_Entry_T<TAO_Notify_ProxyConsumer> *, ACE_Hash<TAO_Notify_EventType>, ACE_Equal_To<TAO_Notify_EventType>, ACE_Null_Mutex> - -#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex> - -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex> -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h index bb9aaa8159d..c43d82dffa8 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h @@ -13,7 +13,9 @@ #define TAO_Notify_EVENT_MANAGER_H #include /**/ "ace/pre.h" +#include "ace/Auto_Ptr.h" +#include "Refcountable.h" #include "notify_serv_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -30,15 +32,15 @@ class TAO_Notify_ProxySupplier; class TAO_Notify_ProxyConsumer; class TAO_Notify_EventTypeSeq; -template <class PROXY, class ACE_LOCK> +template <class PROXY, class ACE_LOCK> class TAO_Notify_Event_Map_T; -typedef TAO_Notify_Event_Map_T<TAO_Notify_ProxySupplier, - TAO_SYNCH_RW_MUTEX> +typedef TAO_Notify_Event_Map_T<TAO_Notify_ProxySupplier, + TAO_SYNCH_RW_MUTEX> TAO_Notify_Consumer_Map; -typedef TAO_Notify_Event_Map_T<TAO_Notify_ProxyConsumer, - TAO_SYNCH_RW_MUTEX> +typedef TAO_Notify_Event_Map_T<TAO_Notify_ProxyConsumer, + TAO_SYNCH_RW_MUTEX> TAO_Notify_Supplier_Map; /** @@ -47,14 +49,17 @@ typedef TAO_Notify_Event_Map_T<TAO_Notify_ProxyConsumer, * @brief A class that manages the Consumer and Supplier maps. * */ -class TAO_Notify_Serv_Export TAO_Notify_Event_Manager +class TAO_Notify_Serv_Export TAO_Notify_Event_Manager : public TAO_Notify_Refcountable { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_Event_Manager > Ptr; /// Constuctor TAO_Notify_Event_Manager (void); /// Destructor - ~TAO_Notify_Event_Manager (); + virtual ~TAO_Notify_Event_Manager (); + + void release(); /// Init void init (ACE_ENV_SINGLE_ARG_DECL); @@ -75,8 +80,8 @@ public: void disconnect (TAO_Notify_ProxyConsumer* proxy_consumer ACE_ENV_ARG_DECL); /// Map accessors. - TAO_Notify_Consumer_Map* consumer_map (void); - TAO_Notify_Supplier_Map* supplier_map (void); + TAO_Notify_Consumer_Map& consumer_map (void); + TAO_Notify_Supplier_Map& supplier_map (void); /// Offer change received on <proxy_consumer>. void offer_change (TAO_Notify_ProxyConsumer* proxy_consumer, const TAO_Notify_EventTypeSeq& added, const TAO_Notify_EventTypeSeq& removed ACE_ENV_ARG_DECL); @@ -85,10 +90,10 @@ public: void subscription_change (TAO_Notify_ProxySupplier* proxy_supplier, const TAO_Notify_EventTypeSeq& added, const TAO_Notify_EventTypeSeq& removed ACE_ENV_ARG_DECL); /// What are the types being offered. - const TAO_Notify_EventTypeSeq& offered_types (void); + const TAO_Notify_EventTypeSeq& offered_types (void) const; /// What are the types being subscribed. - const TAO_Notify_EventTypeSeq& subscription_types (void); + const TAO_Notify_EventTypeSeq& subscription_types (void) const; protected: /// Subscribe <proxy_supplier> to the event type sequence list <seq>. @@ -103,11 +108,12 @@ protected: /// Subscribe <proxy_consumer> to the event type sequence list <seq>. void un_publish (TAO_Notify_ProxyConsumer* proxy_consumer, const TAO_Notify_EventTypeSeq& seq, TAO_Notify_EventTypeSeq& last_seq ACE_ENV_ARG_DECL); +private: /// Consumer Map - TAO_Notify_Consumer_Map* consumer_map_; + ACE_Auto_Ptr< TAO_Notify_Consumer_Map > consumer_map_; /// Supplier Map - TAO_Notify_Supplier_Map* supplier_map_; + ACE_Auto_Ptr< TAO_Notify_Supplier_Map > supplier_map_; }; /********************************************************************************/ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl index 96ea18453c4..30bac38318d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl @@ -4,26 +4,28 @@ #include "ProxySupplier.h" #include "Event_Map_T.h" -ACE_INLINE TAO_Notify_Consumer_Map* +ACE_INLINE TAO_Notify_Consumer_Map& TAO_Notify_Event_Manager::consumer_map (void) { - return this->consumer_map_; + ACE_ASSERT( this->consumer_map_.get() != 0 ); + return *this->consumer_map_; } -ACE_INLINE TAO_Notify_Supplier_Map* +ACE_INLINE TAO_Notify_Supplier_Map& TAO_Notify_Event_Manager::supplier_map (void) { - return this->supplier_map_; + ACE_ASSERT( this->supplier_map_.get() != 0 ); + return *this->supplier_map_; } ACE_INLINE const TAO_Notify_EventTypeSeq& -TAO_Notify_Event_Manager::offered_types (void) +TAO_Notify_Event_Manager::offered_types (void) const { return this->supplier_map_->event_types (); } ACE_INLINE const TAO_Notify_EventTypeSeq& -TAO_Notify_Event_Manager::subscription_types (void) +TAO_Notify_Event_Manager::subscription_types (void) const { return this->consumer_map_->event_types (); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Persistence_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Persistence_Factory.h index e050f65f881..2f36805859e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Event_Persistence_Factory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Persistence_Factory.h @@ -32,8 +32,7 @@ namespace TAO_Notify class TAO_Notify_Serv_Export Event_Persistence_Factory { public: - /// Destructor. - virtual ~Event_Persistence_Factory (void); + virtual ~Event_Persistence_Factory(); /// Create a Persistence Manager virtual Routing_Slip_Persistence_Manager * diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp index 2ed14807e59..7f961da6692 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp @@ -10,7 +10,7 @@ ACE_RCSID(Notify, FilterAdmin, "$Id$") #include "Topology_Saver.h" #include "Properties.h" -#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Bound_Ptr.h" // Implementation skeleton constructor TAO_Notify_FilterAdmin::TAO_Notify_FilterAdmin (void) diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h index d6e20116940..c1faf85d5eb 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h @@ -43,7 +43,7 @@ class TAO_Notify_Serv_Export TAO_Notify_FilterAdmin // = match operation on all the filters /// See if any of the filters match. - CORBA::Boolean match (const TAO_Notify_Event_var &event ACE_ENV_ARG_DECL) + CORBA::Boolean match (const TAO_Notify_Event::Ptr &event ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException, CosNotifyFilter::UnsupportedFilterableData @@ -88,10 +88,11 @@ class TAO_Notify_Serv_Export TAO_Notify_FilterAdmin virtual void save_persistent (TAO_Notify::Topology_Saver& saver ACE_ENV_ARG_DECL); virtual TAO_Notify::Topology_Object* load_child (const ACE_CString &type, CORBA::Long id, const TAO_Notify::NVPList& attrs ACE_ENV_ARG_DECL); - virtual void release (void); private: typedef ACE_Hash_Map_Manager <CosNotifyFilter::FilterID, CosNotifyFilter::Filter_var, ACE_SYNCH_NULL_MUTEX> FILTER_LIST; + virtual void release (void); + /// Mutex to serialize access to data members. TAO_SYNCH_MUTEX lock_; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h index 86c8b564a04..1148715ed8e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h @@ -19,7 +19,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Message_Block.h" -#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Bound_Ptr.h" #include "ace/OS_NS_sys_time.h" #include "Event.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl index 619cfbefa56..2ff54e674fb 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl @@ -1,10 +1,12 @@ // $Id$ #include "ace/OS_NS_sys_time.h" +#include "orbsvcs/Time_Utilities.h" ACE_INLINE void -TAO_Notify_Method_Request_Queueable::init (const TAO_Notify_Event * event) +TAO_Notify_Method_Request_Queueable::init (const TAO_Notify_Event* event) { + ACE_ASSERT( event != 0 ); // Set the parameters that affect queuing in the message queue. // The ACE_Message_Block priorities go from 0 (lowest) to ULONG_MAX // (highest), while the Notification Events go from -32767 (lowest, @@ -14,8 +16,7 @@ TAO_Notify_Method_Request_Queueable::init (const TAO_Notify_Event * event) // unsigned long will happen automatically and we do not have to worry // about losing the number in the addition since priority () returns a // CORBA::Short. - this->msg_priority ((CORBA::Long)event->priority ().value () + - PRIORITY_BASE); + this->msg_priority ((CORBA::Long)event->priority ().value () + PRIORITY_BASE); // The deadline time for the message block is absolute, while the // timeout for the event is relative to the time it was received. @@ -25,17 +26,9 @@ TAO_Notify_Method_Request_Queueable::init (const TAO_Notify_Event * event) if (timeout.is_valid () && timeout != 0) { - // I am multiplying timeout () by 1 because it returns a - // CORBA::ULongLong, which on some platforms doesn't automatically - // convert to the long that the ACE_Time_Value expects. The / - // operator returns a 32-bit integer. - ACE_Time_Value current = ACE_OS::gettimeofday () + -# if defined (ACE_CONFIG_WIN32_H) - ACE_Time_Value ( - static_cast<long> (timeout.value ())); -# else - ACE_Time_Value (timeout.value () / 1); -# endif /* ACE_CONFIG_WIN32_H */ - this->msg_deadline_time (current); + ACE_Time_Value deadline; + ORBSVCS_Time::TimeT_to_Time_Value(deadline, timeout.value()); + deadline += ACE_OS::gettimeofday (); + this->msg_deadline_time (deadline); } } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp index 359160773ef..5b3d5c937b9 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp @@ -68,10 +68,10 @@ int TAO_Notify_Method_Request_Dispatch::execute_i (ACE_ENV_SINGLE_ARG_DECL) if (this->filtering_ == 1) { - TAO_Notify_Admin* parent = this->proxy_supplier_->consumer_admin (); + TAO_Notify_Admin& parent = this->proxy_supplier_->consumer_admin (); CORBA::Boolean val = this->proxy_supplier_->check_filters (this->event_, - parent->filter_admin (), - parent->filter_operator () + parent.filter_admin (), + parent.filter_operator () ACE_ENV_ARG_PARAMETER); if (TAO_debug_level > 1) @@ -188,11 +188,12 @@ TAO_Notify_Method_Request_Dispatch::unmarshal ( // of the one in the previous method request TAO_Notify_Method_Request_Dispatch_Queueable::TAO_Notify_Method_Request_Dispatch_Queueable ( const TAO_Notify_Method_Request_Event & request, - TAO_Notify_Event_var & event, + TAO_Notify_Event::Ptr & event, TAO_Notify_ProxySupplier* proxy_supplier, bool filtering) : TAO_Notify_Method_Request_Dispatch (request, event.get (), proxy_supplier, filtering) , TAO_Notify_Method_Request_Queueable (event.get ()) + , event_var_( event ) { #if 0 ACE_DEBUG ((LM_DEBUG, @@ -209,6 +210,8 @@ TAO_Notify_Method_Request_Dispatch_Queueable::TAO_Notify_Method_Request_Dispatch bool filtering) : TAO_Notify_Method_Request_Dispatch (request, request->event ().get (), proxy_supplier, filtering) , TAO_Notify_Method_Request_Queueable (request->event ().get ()) + , event_var_( request->event () ) + { #if 0 ACE_DEBUG ((LM_DEBUG, @@ -280,8 +283,8 @@ TAO_Notify_Method_Request_Dispatch_No_Copy::copy (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_Method_Request_Queueable* request; - TAO_Notify_Event_var event_var; - this->event_->queueable_copy (event_var ACE_ENV_ARG_PARAMETER); + TAO_Notify_Event::Ptr event_var ( + this->event_->queueable_copy (ACE_ENV_SINGLE_ARG_PARAMETER) ); ACE_CHECK_RETURN (0); ACE_NEW_THROW_EX (request, diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h index 55e59b143eb..73d0b028a3d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h @@ -81,8 +81,7 @@ protected: protected: /// The Proxy - TAO_Notify_ProxySupplier_Guard proxy_supplier_; - //TAO_Notify_ProxySupplier* proxy_supplier_; + TAO_Notify_ProxySupplier::Ptr proxy_supplier_; /// Flag is true if we want to do filtering else false. bool filtering_; @@ -105,7 +104,7 @@ public: /// of the one in the previous method request TAO_Notify_Method_Request_Dispatch_Queueable ( const TAO_Notify_Method_Request_Event & request, - TAO_Notify_Event_var & event, + TAO_Notify_Event::Ptr & event, TAO_Notify_ProxySupplier* proxy_supplier, bool filtering); @@ -117,14 +116,14 @@ public: bool filtering); /// Destructor - ~TAO_Notify_Method_Request_Dispatch_Queueable (); + virtual ~TAO_Notify_Method_Request_Dispatch_Queueable (); /// Execute the Request virtual int execute (ACE_ENV_SINGLE_ARG_DECL); private: - const TAO_Notify_Event_var event_var_; - TAO_Notify_ProxySupplier_Guard proxy_guard_; + const TAO_Notify_Event::Ptr event_var_; + TAO_Notify_ProxySupplier::Ptr proxy_guard_; }; /*******************************************************************************************************/ @@ -153,7 +152,7 @@ public: bool filtering); /// Destructor - ~TAO_Notify_Method_Request_Dispatch_No_Copy (); + virtual ~TAO_Notify_Method_Request_Dispatch_No_Copy (); /// Execute the Request virtual int execute (ACE_ENV_SINGLE_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Event.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Event.cpp index 5a5f0fd1c4b..4b479d58128 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Event.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Event.cpp @@ -65,7 +65,7 @@ TAO_Notify_Method_Request_Event::should_retry () TAO_Notify_Method_Request_Event_Queueable::TAO_Notify_Method_Request_Event_Queueable ( const TAO_Notify_Method_Request_Event & prev_request, - const TAO_Notify_Event_var & event_var) + const TAO_Notify_Event::Ptr & event_var) : TAO_Notify_Method_Request_Queueable (event_var.get ()) , TAO_Notify_Method_Request_Event (prev_request, event_var.get ()) , event_var_ (event_var) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Event.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Event.h index 64d17d48f58..437aa08187d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Event.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Event.h @@ -83,7 +83,7 @@ public: /// exceptions from the constructor if it's necessary to copy the event. TAO_Notify_Method_Request_Event_Queueable ( const TAO_Notify_Method_Request_Event & prev_request, - const TAO_Notify_Event_var & event_var); + const TAO_Notify_Event::Ptr & event_var); TAO_Notify_Method_Request_Event_Queueable ( TAO_Notify::Delivery_Request_Ptr & request); @@ -94,7 +94,7 @@ public: /// satisfy the pure virtual method. Should never be called. virtual int execute (ACE_ENV_SINGLE_ARG_DECL); private: - TAO_Notify_Event_var event_var_; + TAO_Notify_Event::Ptr event_var_; }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp index 34332749637..0f2c5367d13 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp @@ -50,11 +50,11 @@ int TAO_Notify_Method_Request_Lookup::execute_i (ACE_ENV_SINGLE_ARG_DECL) if (this->proxy_consumer_->has_shutdown ()) return 0; // If we were shutdown while waiting in the queue, return with no action. - TAO_Notify_SupplierAdmin* parent = this->proxy_consumer_->supplier_admin (); + TAO_Notify_SupplierAdmin& parent = this->proxy_consumer_->supplier_admin (); CORBA::Boolean val = this->proxy_consumer_->check_filters (this->event_, - parent->filter_admin (), - parent->filter_operator () + parent.filter_admin (), + parent.filter_operator () ACE_ENV_ARG_PARAMETER); if (TAO_debug_level > 1) @@ -65,9 +65,9 @@ int TAO_Notify_Method_Request_Lookup::execute_i (ACE_ENV_SINGLE_ARG_DECL) return 0; // The map of subscriptions. - TAO_Notify_Consumer_Map* map = this->proxy_consumer_->event_manager ()->consumer_map (); + TAO_Notify_Consumer_Map& map = this->proxy_consumer_->event_manager ().consumer_map (); - TAO_Notify_Consumer_Map::ENTRY* entry = map->find (this->event_->type () ACE_ENV_ARG_PARAMETER); + TAO_Notify_Consumer_Map::ENTRY* entry = map.find (this->event_->type () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); TAO_Notify_ProxySupplier_Collection* consumers = 0; @@ -79,11 +79,11 @@ int TAO_Notify_Method_Request_Lookup::execute_i (ACE_ENV_SINGLE_ARG_DECL) if (consumers != 0) consumers->for_each (this ACE_ENV_ARG_PARAMETER); - map->release (entry); + map.release (entry); } // Get the default consumers - consumers = map->broadcast_collection (); + consumers = map.broadcast_collection (); if (consumers != 0) consumers->for_each (this ACE_ENV_ARG_PARAMETER); @@ -151,7 +151,7 @@ TAO_Notify_Method_Request_Lookup::unmarshal ( /****************************************************************/ TAO_Notify_Method_Request_Lookup_Queueable::TAO_Notify_Method_Request_Lookup_Queueable ( - const TAO_Notify_Event_var& event, + const TAO_Notify_Event::Ptr& event, TAO_Notify_ProxyConsumer* proxy_consumer) : TAO_Notify_Method_Request_Lookup (event.get (), proxy_consumer) , TAO_Notify_Method_Request_Queueable (event.get ()) @@ -205,8 +205,8 @@ TAO_Notify_Method_Request_Lookup_No_Copy::copy (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_Method_Request_Queueable* request; - TAO_Notify_Event_var event_var; - this->event_->queueable_copy (event_var ACE_ENV_ARG_PARAMETER); + TAO_Notify_Event::Ptr event_var ( + this->event_->queueable_copy (ACE_ENV_SINGLE_ARG_PARAMETER) ); ACE_CHECK_RETURN (0); ACE_NEW_THROW_EX (request, @@ -215,29 +215,3 @@ TAO_Notify_Method_Request_Lookup_No_Copy::copy (ACE_ENV_SINGLE_ARG_DECL) return request; } -#if 0 -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class TAO_Notify_Method_Request_Lookup_T<const TAO_Notify_Event_var -, TAO_Notify_ProxyConsumer_Guard -, const TAO_Notify_Event_var& -, TAO_Notify_ProxyConsumer*>; - -template class TAO_Notify_Method_Request_Lookup_T<const TAO_Notify_Event* -, TAO_Notify_ProxyConsumer* -, const TAO_Notify_Event* -, TAO_Notify_ProxyConsumer*>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate TAO_Notify_Method_Request_Lookup_T<const TAO_Notify_Event_var -, TAO_Notify_ProxyConsumer_Guard -, const TAO_Notify_Event_var& -, TAO_Notify_ProxyConsumer*> - -#pragma instantiate TAO_Notify_Method_Request_Lookup_T<const TAO_Notify_Event* -, TAO_Notify_ProxyConsumer* -, const TAO_Notify_Event* -, TAO_Notify_ProxyConsumer*> -#endif -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h index 66d9de69c7a..1b58917608d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h @@ -85,7 +85,7 @@ class TAO_Notify_Serv_Export TAO_Notify_Method_Request_Lookup_Queueable public: /// Constuctor from event TAO_Notify_Method_Request_Lookup_Queueable ( - const TAO_Notify_Event_var& event, + const TAO_Notify_Event::Ptr& event, TAO_Notify_ProxyConsumer * proxy_consumer); /// Constuctor from delivery request @@ -94,14 +94,14 @@ public: TAO_Notify_ProxyConsumer * proxy_consumer); /// Destructor - ~TAO_Notify_Method_Request_Lookup_Queueable (); + virtual ~TAO_Notify_Method_Request_Lookup_Queueable (); /// Execute the Request virtual int execute (ACE_ENV_SINGLE_ARG_DECL); private: - const TAO_Notify_Event_var event_var_; - TAO_Notify_ProxyConsumer_Guard proxy_guard_; + const TAO_Notify_Event::Ptr event_var_; + TAO_Notify_ProxyConsumer::Ptr proxy_guard_; }; /*****************************************************************************************************************************/ @@ -123,7 +123,7 @@ public: TAO_Notify_ProxyConsumer* proxy_consumer); /// Destructor - ~TAO_Notify_Method_Request_Lookup_No_Copy (); + virtual ~TAO_Notify_Method_Request_Lookup_No_Copy (); /// Execute the Request virtual int execute (ACE_ENV_SINGLE_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h index 0b8259583e8..aa93b347070 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h @@ -36,7 +36,7 @@ public: TAO_Notify_Method_Request_Shutdown (TAO_Notify_ThreadPool_Task* task); /// Destructor - ~TAO_Notify_Method_Request_Shutdown (); + virtual ~TAO_Notify_Method_Request_Shutdown (); /// Create a copy of this object. TAO_Notify_Method_Request_Queueable* copy (void); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.cpp index bf2c0f0d23d..4e89758faf0 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.cpp @@ -56,7 +56,7 @@ TAO_Notify_Method_Request_Updates_No_Copy::execute (ACE_ENV_SINGLE_ARG_DECL) #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class TAO_Notify_Method_Request_Updates_T<const TAO_Notify_EventTypeSeq -, TAO_Notify_Proxy_Guard +, TAO_Notify_Proxy::Ptr , const TAO_Notify_EventTypeSeq& , TAO_Notify_Proxy* >; @@ -70,7 +70,7 @@ template class TAO_Notify_Method_Request_Updates_T<const TAO_Notify_EventTypeSeq #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate TAO_Notify_Method_Request_Updates_T<const TAO_Notify_EventTypeSeq -, TAO_Notify_Proxy_Guard +, TAO_Notify_Proxy::Ptr , const TAO_Notify_EventTypeSeq& , TAO_Notify_Proxy* > diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.h index 05ac8f470e7..b072288cf26 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Updates.h @@ -25,7 +25,7 @@ #include "Proxy.h" typedef TAO_Notify_Method_Request_Updates_T<const TAO_Notify_EventTypeSeq - , TAO_Notify_Proxy_Guard + , TAO_Notify_Proxy::Ptr , const TAO_Notify_EventTypeSeq& , TAO_Notify_Proxy* > TAO_Notify_Method_Request_Updates_Base; @@ -44,7 +44,7 @@ public: TAO_Notify_Method_Request_Updates (const TAO_Notify_EventTypeSeq& added, const TAO_Notify_EventTypeSeq& removed, TAO_Notify_Proxy* proxy); /// Destructor - ~TAO_Notify_Method_Request_Updates (); + virtual ~TAO_Notify_Method_Request_Updates (); /// Execute the Request virtual int execute (ACE_ENV_SINGLE_ARG_DECL); @@ -72,7 +72,7 @@ public: TAO_Notify_Method_Request_Updates_No_Copy (const TAO_Notify_EventTypeSeq& added, const TAO_Notify_EventTypeSeq& removed, TAO_Notify_Proxy* proxy); /// Destructor - ~TAO_Notify_Method_Request_Updates_No_Copy (); + virtual ~TAO_Notify_Method_Request_Updates_No_Copy (); /// Create a copy of this object. virtual TAO_Notify_Method_Request_Queueable* copy (ACE_ENV_SINGLE_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Name_Value_Pair.cpp b/TAO/orbsvcs/orbsvcs/Notify/Name_Value_Pair.cpp index 42b7d214a3c..1032bac7d51 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Name_Value_Pair.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Name_Value_Pair.cpp @@ -55,14 +55,14 @@ namespace TAO_Notify NVP::NVP(const TAO_Notify_Property_Time& p) : name(p.name()) { - char buf[128]; + ACE_TCHAR buf[128]; ACE_UINT64 us = p.value(); #ifdef ACE_LACKS_LONGLONG_T us.as_string(buf); #else ACE_OS::sprintf(buf, ACE_UINT64_FORMAT_SPECIFIER, us); #endif /* ACE_LACKS_LONGLONG_T */ - value = buf; + value = ACE_TEXT_ALWAYS_CHAR (buf); } NVP::NVP(const TAO_Notify_Property_Boolean& p) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.h index efc137b0972..1eb9eac1efe 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Interpreter.h @@ -39,7 +39,7 @@ public: TAO_Notify_Constraint_Interpreter (void); /// Destructor - ~TAO_Notify_Constraint_Interpreter (void); + virtual ~TAO_Notify_Constraint_Interpreter (void); /** * This method builds an expression tree representing the diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.cpp index ff02fbe9702..5dcd59297c3 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.cpp @@ -480,12 +480,14 @@ TAO_Notify_Constraint_Visitor::visit_component_assoc ( return 0; } - + else + { ACE_NEW_RETURN (any_ptr, CORBA::Any (*any), -1); this->current_value_ = any_ptr; return comp->accept (this); + } } int @@ -586,8 +588,7 @@ TAO_Notify_Constraint_Visitor::visit_special (TAO_ETCL_Special *special) ACE_TRY { CORBA::TypeCode_var tc = this->current_value_->type (); - tc = TAO_DynAnyFactory::strip_alias (tc.in () - ACE_ENV_ARG_PARAMETER); + tc = TAO_DynAnyFactory::strip_alias (tc.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; switch (special->type ()) @@ -596,10 +597,7 @@ TAO_Notify_Constraint_Visitor::visit_special (TAO_ETCL_Special *special) { CORBA::ULong length; - CORBA::TCKind const kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - switch (kind) + switch (tc->kind ()) { case CORBA::tk_sequence: { diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.h index 97a3fb9977a..e6be5e16947 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Constraint_Visitors.h @@ -24,14 +24,13 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "orbsvcs/ETCL/ETCL_Constraint_Visitor.h" +#include "orbsvcs/ETCL/ETCL_Constraint.h" #include "orbsvcs/CosNotificationC.h" -#include "tao/TypeCode.h" +#include "tao/Typecode.h" #include "notify_serv_export.h" -class TAO_ETCL_Constraint; -class TAO_ETCL_Literal_Constraint; class TAO_Notify_Property_Constraint; class TAO_Notify_Serv_Export TAO_Notify_Constraint_Visitor diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp index 0c24d0b14af..83420ad3fff 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp @@ -27,7 +27,7 @@ TAO_Notify_EventChannelFactory_i::create (PortableServer::POA_ptr default_POA AC CORBA::ORB_ptr orb = poa->orb_core ().orb () ; - notify_service->init (orb ACE_ENV_ARG_PARAMETER); + notify_service->init_service (orb ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (notify_factory._retn ()); notify_factory = notify_service->create (default_POA ACE_ENV_ARG_PARAMETER); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.cpp b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp index 33e2bc9f7f0..d449d9b3dcb 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp @@ -7,6 +7,7 @@ #include "Builder.h" #include "ThreadPool_Task.h" #include "Reactive_Task.h" +#include "Event_Manager.h" #include "tao/debug.h" #if ! defined (__ACE_INLINE__) @@ -18,17 +19,14 @@ ACE_RCSID(Notify, TAO_Notify_Object, "$Id$") TAO_Notify_Object::TAO_Notify_Object (void) - : event_manager_ (0) - , admin_properties_ (0) - , id_ (0) - , poa_ (0) + : poa_ (0) , proxy_poa_ (0) - , own_proxy_poa_ (0) + , own_proxy_poa_ (false) , object_poa_ (0) - , own_object_poa_ (0) - , worker_task_ (0) - , own_worker_task_ (0) - , shutdown_ (0) + , own_object_poa_ (false) + , id_ (0) + , own_worker_task_ (false) + , shutdown_ (false) { if (TAO_debug_level > 2 ) ACE_DEBUG ((LM_DEBUG,"object:%x created\n", this )); @@ -39,29 +37,36 @@ TAO_Notify_Object::~TAO_Notify_Object () if (TAO_debug_level > 2 ) ACE_DEBUG ((LM_DEBUG,"object:%x destroyed\n", this )); - this->shutdown_proxy_poa (); - this->shutdown_object_poa (); + this->destroy_proxy_poa (); + this->destroy_object_poa (); + this->destroy_poa (); } void TAO_Notify_Object::initialize (TAO_Notify_Object* parent) { + ACE_ASSERT (parent != 0 && this->event_manager_.get() == 0); + + // Do not use sets to avoid asserts. + // Object must be able to inherit NULL references + // due to current design. this->event_manager_ = parent->event_manager_; this->admin_properties_ = parent->admin_properties_; - - this->poa_ = parent->poa_; - this->object_poa_ = parent->object_poa_; - this->proxy_poa_ = parent->proxy_poa_; + this->inherit_poas( *parent ); this->worker_task_ = parent->worker_task_; - if (this->worker_task_) - this->worker_task_->_incr_refcnt (); - // Pass QoS parent->qos_properties_.transfer (this->qos_properties_); this->qos_changed (this->qos_properties_); } +void +TAO_Notify_Object::set_event_manager( TAO_Notify_Event_Manager* event_manager ) +{ + ACE_ASSERT( event_manager != 0 ); + this->event_manager_.reset( event_manager ); +} + CORBA::Object_ptr TAO_Notify_Object::activate (PortableServer::Servant servant ACE_ENV_ARG_DECL) { @@ -90,12 +95,12 @@ TAO_Notify_Object::deactivate (ACE_ENV_SINGLE_ARG_DECL) } ACE_CATCHANY { + // Do not propagate any exceptions if (TAO_debug_level > 2) { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "(%P|%t)\n"); ACE_DEBUG ((LM_DEBUG, "Could not deactivate object %d\n", this->id_)); } - // Do not propagate any exceptions } ACE_ENDTRY; } @@ -129,26 +134,35 @@ void TAO_Notify_Object::shutdown_worker_task (void) { // Only do this if we are the owner. - if (this->own_worker_task_ == 1) + TAO_Notify_Worker_Task::Ptr task( this->worker_task_ ); + this->worker_task_.reset(); + if ( task.isSet() ) + { + if ( this->own_worker_task_ ) { - this->worker_task_->shutdown (); // the worker deletes itself when its <close> hook is eventually called. + task->shutdown (); + } } - - if (this->worker_task_) - this->worker_task_->_decr_refcnt (); } void -TAO_Notify_Object::shutdown_proxy_poa (void) +TAO_Notify_Object::destroy_proxy_poa (void) { - if (this->own_proxy_poa_ == 1) + if (this->proxy_poa_ != 0) { ACE_TRY_NEW_ENV { + if ( this->proxy_poa_ == this->object_poa_ ) this->object_poa_ = 0; + if ( this->proxy_poa_ == this->poa_ ) this->poa_ = 0; + + if ( this->own_proxy_poa_ == true ) + { + this->own_proxy_poa_ = false; + ACE_Auto_Ptr< TAO_Notify_POA_Helper > app( object_poa_ ); this->proxy_poa_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - - delete this->proxy_poa_; + } + this->proxy_poa_ = 0; } ACE_CATCHANY { @@ -161,16 +175,23 @@ TAO_Notify_Object::shutdown_proxy_poa (void) } void -TAO_Notify_Object::shutdown_object_poa (void) +TAO_Notify_Object::destroy_object_poa (void) { - if (this->own_object_poa_ == 1) + if (this->object_poa_ != 0) { ACE_TRY_NEW_ENV { + if ( this->object_poa_ == this->proxy_poa_ ) this->proxy_poa_ = 0; + if ( this->object_poa_ == this->poa_ ) this->poa_ = 0; + + if ( this->own_object_poa_ == true ) + { + this->own_object_poa_ = false; + ACE_Auto_Ptr< TAO_Notify_POA_Helper > aop( object_poa_ ); this->object_poa_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - - delete this->object_poa_; + } + this->object_poa_ = 0; } ACE_CATCHANY { @@ -182,52 +203,51 @@ TAO_Notify_Object::shutdown_object_poa (void) } } -void -TAO_Notify_Object::worker_task_own (TAO_Notify_Worker_Task* worker_task) +/// Shutdown the current poa. +void TAO_Notify_Object::destroy_poa (void) { - this->worker_task (worker_task); - - // claim ownership. - this->own_worker_task_ = 1; + this->poa_ = 0; } void -TAO_Notify_Object::worker_task (TAO_Notify_Worker_Task* worker_task) +TAO_Notify_Object::set_worker_task (TAO_Notify_Worker_Task* worker_task) { + ACE_ASSERT( worker_task != 0 ); + // shutdown the current worker. this->shutdown_worker_task (); - this->worker_task_ = worker_task; + this->worker_task_.reset (worker_task); - this->own_worker_task_ = 0; + this->own_worker_task_ = true; - if (this->worker_task_) - this->worker_task_->_incr_refcnt (); } void -TAO_Notify_Object::proxy_poa_own (TAO_Notify_POA_Helper* proxy_poa) +TAO_Notify_Object::set_proxy_poa (TAO_Notify_POA_Helper* proxy_poa) { // shutdown current proxy poa. - this->shutdown_proxy_poa (); + this->destroy_proxy_poa (); this->proxy_poa_ = proxy_poa; - // claim ownership. - own_proxy_poa_ = 1; + this->own_proxy_poa_ = true; } void -TAO_Notify_Object::object_poa_own (TAO_Notify_POA_Helper* object_poa) +TAO_Notify_Object::set_object_poa (TAO_Notify_POA_Helper* object_poa) { // shutdown current object poa. - this->shutdown_object_poa (); + this->destroy_object_poa (); - // shutdown current object poa this->object_poa_ = object_poa; - // claim ownership. - this->own_object_poa_ = 1; + this->own_object_poa_ = true; +} +void +TAO_Notify_Object::set_poa (TAO_Notify_POA_Helper* poa) +{ + this->poa_ = poa; } void @@ -300,6 +320,7 @@ TAO_Notify_Object::qos_changed (const TAO_Notify_QoSProperties& /*qos_properties TAO_Notify_Timer* TAO_Notify_Object::timer (void) { + ACE_ASSERT (worker_task_.get() != 0); return this->worker_task_->timer (); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.h b/TAO/orbsvcs/orbsvcs/Notify/Object.h index 43bea7ac4d5..6ca44392459 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.h @@ -26,13 +26,14 @@ #include "QoSProperties.h" #include "AdminProperties.h" +#include "Worker_Task.h" #include "Refcountable.h" #include "Name_Value_Pair.h" -class TAO_Notify_POA_Helper; -class TAO_Notify_Worker_Task; class TAO_Notify_Event_Manager; +class TAO_Notify_POA_Helper; class TAO_Notify_Timer; +class TAO_Notify_RT_Builder; /** * @class TAO_Notify_Object @@ -43,14 +44,12 @@ class TAO_Notify_Timer; class TAO_Notify_Serv_Export TAO_Notify_Object : public TAO_Notify_Refcountable { friend class TAO_Notify_Builder; + friend class TAO_Notify_RT_Builder; public: /// Id for Objects. typedef CORBA::Long ID; - /// Constuctor - TAO_Notify_Object (void); - /// Destructor virtual ~TAO_Notify_Object (void); @@ -72,33 +71,11 @@ public: /// Have we been shutdown. returns 1 if shutdown. int has_shutdown (void); + void execute_task (TAO_Notify_Method_Request& method_request ACE_ENV_ARG_DECL); + /// Get CORBA Ref. CORBA::Object_ptr ref (ACE_ENV_SINGLE_ARG_DECL); - /// Get Worker Task. - TAO_Notify_Worker_Task* worker_task (void); - - /// Get the POA assigned to us. - TAO_Notify_POA_Helper* poa (void); - - /// Setting the proxy_poa_ gives ownership to this class. - void proxy_poa_own (TAO_Notify_POA_Helper* proxy_poa); - - /// Accessor for the proxy_poa_ - TAO_Notify_POA_Helper* proxy_poa (void); - - /// Setting the object_poa_ gives ownership to this class. - void object_poa_own (TAO_Notify_POA_Helper* object_poa); - - /// Accessor for the object_poa_ - TAO_Notify_POA_Helper* object_poa (void); - - /// Set Worker Task. This object assume ownership of the set object. - void worker_task_own (TAO_Notify_Worker_Task* worker_task); - - /// Set Worker Task. Does not assume ownership. - void worker_task (TAO_Notify_Worker_Task* worker_task); - /// Set the QoS Properties. virtual void set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL); @@ -112,28 +89,49 @@ public: /// Obtain the Timer manager associated with this object. virtual TAO_Notify_Timer* timer (void); + /// Accessor for the Event Manager + TAO_Notify_Event_Manager& event_manager (void); + /// shutdown. Returns 1 ifif the shutdown was already run once before. virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); - /// Accessor for the Event Manager - TAO_Notify_Event_Manager* event_manager (void); - /// Load our attributes. Each derived type should call the superclass /// load first before loading its own attributes. virtual void load_attrs(const TAO_Notify::NVPList& attrs); protected: + /// Constructor + TAO_Notify_Object (void); + /// Init this object with data from <rhs>. void initialize (TAO_Notify_Object* parent); - /// Shutdown the current worker task and delete it if we own it. - void shutdown_worker_task (void); + /// Uses the poas from the supplied object + void inherit_poas (TAO_Notify_Object& parent); - /// Shutdown the current proxy poa. - void shutdown_proxy_poa (void); + /// Adopts the supplied poa as all are poas + void adopt_poa (TAO_Notify_POA_Helper* single); - /// Shutdown the current object poa. - void shutdown_object_poa (void); + /// Changes the primary poa to the current proxy poa + void set_primary_as_proxy_poa(); + + /// Accessor for the proxy_poa_ + TAO_Notify_POA_Helper* proxy_poa (void); + + /// Accessor for the object_poa_ + TAO_Notify_POA_Helper* object_poa (void); + + /// Get the POA assigned to us. + TAO_Notify_POA_Helper* poa (void); + + // Sets the admin properties + void set_event_manager( TAO_Notify_Event_Manager* event_manager ); + + // Sets the admin properties + void set_admin_properties( TAO_Notify_AdminProperties* admin_properties ); + + /// Accessor for the Admin Properties + TAO_Notify_AdminProperties& admin_properties (void); /// Notification that can be overridden by subclasses to be informed that <qos_properties_> have been modified. virtual void qos_changed (const TAO_Notify_QoSProperties& qos_properties); @@ -145,17 +143,35 @@ protected: ///= Protected data members. - /// The event manager. - TAO_Notify_Event_Manager* event_manager_; - - /// Admin Properties. - TAO_Notify_AdminProperties_var admin_properties_; - /// QoS Properties. TAO_Notify_QoSProperties qos_properties_; - /// Id assigned to this object - ID id_; +private: + /// Set Worker Task. This object assume ownership of the set object. + void set_worker_task (TAO_Notify_Worker_Task* worker_task); + + /// Setting the proxy_poa_ gives ownership to this class. + void set_proxy_poa (TAO_Notify_POA_Helper* proxy_poa); + + /// Setting the object_poa_ gives ownership to this class. + void set_object_poa (TAO_Notify_POA_Helper* object_poa); + + /// Setting the object_poa_ gives ownership to this class. + void set_poa (TAO_Notify_POA_Helper* object_poa); + + /// Shutdown the current worker task and delete it if we own it. + void shutdown_worker_task (void); + + /// Shutdown the current proxy poa. + void destroy_proxy_poa (void); + + /// Shutdown the current object poa. + void destroy_object_poa (void); + + /// Shutdown the current poa. + void destroy_poa (void); + + ///= Private data members. /// The POA in which the object is activated. TAO_Notify_POA_Helper* poa_; @@ -163,23 +179,28 @@ protected: /// The POA in which the proxys are activated. TAO_Notify_POA_Helper* proxy_poa_; - /// Flag that indicates if we own <proxy_poa_> - int own_proxy_poa_; + bool own_proxy_poa_; /// The POA in which the object's children are activated. TAO_Notify_POA_Helper* object_poa_; + bool own_object_poa_; - /// Flag that indicates if we own <object_poa_> - int own_object_poa_; + /// Id assigned to this object + ID id_; - /// Worker Task. - TAO_Notify_Worker_Task* worker_task_; + /// The event manager. + //TAO_Notify_Event_Manager inl includes Object.h + TAO_Notify_Refcountable_Guard_T< TAO_Notify_Event_Manager > event_manager_; + + /// Admin Properties. + TAO_Notify_AdminProperties::Ptr admin_properties_; - /// Ownership flag - int own_worker_task_; + /// Worker Task. + TAO_Notify_Worker_Task::Ptr worker_task_; + bool own_worker_task_; /// Are we shutdown (i,e. scheduled for destroy). - int shutdown_; + bool shutdown_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.inl b/TAO/orbsvcs/orbsvcs/Notify/Object.inl index 3a20131bbec..8ea54d6f1f1 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.inl @@ -6,10 +6,43 @@ TAO_Notify_Object::id (void) const return id_; } -ACE_INLINE TAO_Notify_Worker_Task* -TAO_Notify_Object::worker_task (void) +ACE_INLINE void +TAO_Notify_Object::execute_task (TAO_Notify_Method_Request& method_request ACE_ENV_ARG_DECL) { - return this->worker_task_; + TAO_Notify_Worker_Task::Ptr task( this->worker_task_ ); + if ( task.isSet() ) + { + task->execute( method_request ACE_ENV_ARG_PARAMETER ); + } +} + +ACE_INLINE void +TAO_Notify_Object::inherit_poas (TAO_Notify_Object& parent) +{ + this->set_proxy_poa( parent.proxy_poa() ); + this->set_object_poa( parent.object_poa() ); + this->set_poa( parent.poa() ); + + // Do not take ownership of parent's poas + own_proxy_poa_ = false; + own_object_poa_ = false; +} + +ACE_INLINE void +TAO_Notify_Object::adopt_poa (TAO_Notify_POA_Helper* single) +{ + ACE_ASSERT( single != 0 ); + this->set_proxy_poa( single ); + this->set_object_poa( single ); + this->set_poa( single ); + + // Maintain ownership of the poa +} + +ACE_INLINE void +TAO_Notify_Object::set_primary_as_proxy_poa() +{ + this->set_poa( this->proxy_poa() ); } ACE_INLINE TAO_Notify_POA_Helper* @@ -36,8 +69,23 @@ TAO_Notify_Object::has_shutdown (void) return this->shutdown_; } -ACE_INLINE TAO_Notify_Event_Manager* +ACE_INLINE void +TAO_Notify_Object::set_admin_properties( TAO_Notify_AdminProperties* admin_properties ) +{ + ACE_ASSERT( admin_properties != 0 ); + this->admin_properties_.reset( admin_properties ); +} + +ACE_INLINE TAO_Notify_Event_Manager& TAO_Notify_Object::event_manager (void) { - return this->event_manager_; + ACE_ASSERT( this->event_manager_.get() != 0 ); + return *this->event_manager_; +} + +ACE_INLINE TAO_Notify_AdminProperties& +TAO_Notify_Object::admin_properties (void) +{ + ACE_ASSERT( this->admin_properties_.get() != 0 ); + return *this->admin_properties_; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp index d130d84b60a..ae59bea78cf 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp @@ -82,7 +82,7 @@ TAO_Notify_Peer::dispatch_updates (const TAO_Notify_EventTypeSeq & added, const if (cos_added.length () != 0 || cos_removed.length () != 0) { - TAO_Notify_Proxy_Guard proxy_guard(this->proxy ()); // Protect this object from being destroyed in this scope. + TAO_Notify_Proxy::Ptr proxy_guard(this->proxy ()); // Protect this object from being destroyed in this scope. this->dispatch_updates_i (cos_added, cos_removed ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.h b/TAO/orbsvcs/orbsvcs/Notify/Peer.h index 5778281bc71..7b9977c77f2 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Peer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.h @@ -36,6 +36,7 @@ class TAO_Notify_Peer; class TAO_Notify_Serv_Export TAO_Notify_Peer { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_Peer > Ptr; /// Constuctor TAO_Notify_Peer (void); @@ -46,8 +47,6 @@ public: CORBA::ULong _incr_refcnt (void); CORBA::ULong _decr_refcnt (void); - /// Release - virtual void release (void) = 0; /// Shutdown the peer. virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); @@ -74,6 +73,9 @@ protected: virtual void dispatch_updates_i (const CosNotification::EventTypeSeq& added, const CosNotification::EventTypeSeq& removed ACE_ENV_ARG_DECL) = 0; +private: + /// Release + virtual void release (void) = 0; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Persistent_File_Allocator.cpp b/TAO/orbsvcs/orbsvcs/Notify/Persistent_File_Allocator.cpp index 9981c1b4656..8edd870b9c5 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Persistent_File_Allocator.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Persistent_File_Allocator.cpp @@ -13,7 +13,7 @@ namespace TAO_Notify { -Persistent_Callback::~Persistent_Callback (void) +Persistent_Callback::~Persistent_Callback() { } @@ -136,7 +136,7 @@ Persistent_File_Allocator::~Persistent_File_Allocator() } bool -Persistent_File_Allocator::open (const char* filename, +Persistent_File_Allocator::open (const ACE_TCHAR* filename, const size_t block_size) { bool file_opened = this->pstore_.open(filename, block_size); @@ -191,7 +191,7 @@ Persistent_File_Allocator::allocate_at(size_t block_number) } Persistent_Storage_Block* -Persistent_File_Allocator::allocate_nowrite (void) +Persistent_File_Allocator::allocate_nowrite() { Persistent_Storage_Block* result = 0; ACE_NEW_RETURN (result, @@ -327,10 +327,11 @@ Persistent_File_Allocator::shutdown_thread() { if (this->thread_active_) { - ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->queue_lock_); - this->terminate_thread_ = true; - this->wake_up_thread_.signal(); - ace_mon.release(); + { + ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->queue_lock_); + this->terminate_thread_ = true; + this->wake_up_thread_.signal(); + } this->thread_manager_.close(); ACE_ASSERT (!this->terminate_thread_); ACE_ASSERT (!this->thread_active_); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Persistent_File_Allocator.h b/TAO/orbsvcs/orbsvcs/Notify/Persistent_File_Allocator.h index 6c27694aa12..05e50545173 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Persistent_File_Allocator.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Persistent_File_Allocator.h @@ -39,9 +39,7 @@ namespace TAO_Notify class TAO_Notify_Serv_Export Persistent_Callback { public: - /// Destructor. - virtual ~Persistent_Callback (void); - + virtual ~Persistent_Callback(); /// \brief Called by a Persistent_File_Allocator when a write request has /// completed. virtual void persist_complete() = 0; @@ -133,7 +131,7 @@ public: /// The destructor. ~Persistent_File_Allocator(); - bool open (const char* filename, + bool open (const ACE_TCHAR* filename, const size_t block_size = 512); /// \brief Wait for pending I/O and terminate our work thread. diff --git a/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp b/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp index 4ce068a7a2b..56610bec364 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp @@ -16,6 +16,7 @@ TAO_Notify_Properties::TAO_Notify_Properties (void) : factory_ (0) , builder_ (0) , asynch_updates_ (0) + , allow_reconnect_ (false) , updates_ (1) { // In case no conf. file is specified, the EC will default to reactive concurrency. diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp index f4a4869c12f..861dc279f09 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp @@ -29,7 +29,7 @@ CORBA::Object_ptr TAO_Notify_Proxy::activate (PortableServer::Servant servant ACE_ENV_ARG_DECL) { // Set the POA that we use to return our <ref> - this->poa_ = this->proxy_poa_; + this->set_primary_as_proxy_poa(); return TAO_Notify_Object::activate (servant ACE_ENV_ARG_PARAMETER); } @@ -39,14 +39,15 @@ TAO_Notify_Proxy::activate (PortableServer::Servant servant, ACE_ENV_ARG_DECL) { // Set the POA that we use to return our <ref> - this->poa_ = this->proxy_poa_; + this->set_primary_as_proxy_poa(); return TAO_Notify_Object::activate (servant, id ACE_ENV_ARG_PARAMETER); } void TAO_Notify_Proxy::deactivate (ACE_ENV_SINGLE_ARG_DECL) { - this->proxy_poa_->deactivate (this->id_ ACE_ENV_ARG_PARAMETER); + ACE_ASSERT (this->proxy_poa() != 0 ); + this->proxy_poa()->deactivate (this->id() ACE_ENV_ARG_PARAMETER); } void @@ -72,7 +73,7 @@ TAO_Notify_Proxy::types_changed (const TAO_Notify_EventTypeSeq& added, const TAO if (TAO_Notify_PROPERTIES::instance()->asynch_updates () == 1) // if we should send the updates synchronously. { - this->worker_task ()->execute (request ACE_ENV_ARG_PARAMETER); + this->execute_task (request ACE_ENV_ARG_PARAMETER); } else // execute in the current thread context. { diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.h b/TAO/orbsvcs/orbsvcs/Notify/Proxy.h index f98a571a2e0..c213387be0d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Proxy.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.h @@ -24,7 +24,6 @@ #include "EventTypeSeq.h" #include "FilterAdmin.h" #include "Admin.h" -#include "Refcountable_Guard_T.h" class TAO_Notify_Admin; class TAO_Notify_Peer; @@ -41,6 +40,7 @@ class TAO_Notify_Serv_Export TAO_Notify_Proxy friend class TAO_Notify_Peer; public: + typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_Proxy> Ptr; typedef CosNotifyChannelAdmin::ProxyIDSeq SEQ; typedef CosNotifyChannelAdmin::ProxyIDSeq_var SEQ_VAR; @@ -48,7 +48,7 @@ public: TAO_Notify_Proxy (void); /// Destructor - ~TAO_Notify_Proxy (); + virtual ~TAO_Notify_Proxy (); /// Activate virtual CORBA::Object_ptr activate (PortableServer::Servant servant @@ -127,8 +127,6 @@ protected: CORBA::Boolean updates_off_; }; -typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_Proxy> TAO_Notify_Proxy_Guard; - #if defined (__ACE_INLINE__) #include "Proxy.inl" #endif /* __ACE_INLINE__ */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp index 8accd58946f..5ca226ccd8c 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp @@ -28,13 +28,11 @@ ACE_RCSID(RT_Notify, TAO_Notify_ProxyConsumer, "$Id$") TAO_Notify_ProxyConsumer::TAO_Notify_ProxyConsumer (void) : supplier_admin_ (0) - , supplier_ (0) { } TAO_Notify_ProxyConsumer::~TAO_Notify_ProxyConsumer () { - this->supplier_admin_->_decr_refcnt (); } TAO_Notify_Peer* @@ -44,14 +42,14 @@ TAO_Notify_ProxyConsumer::peer (void) } void -TAO_Notify_ProxyConsumer::init (TAO_Notify::Topology_Parent * topology_parent ACE_ENV_ARG_DECL) +TAO_Notify_ProxyConsumer::init (TAO_Notify::Topology_Parent* topology_parent ACE_ENV_ARG_DECL) { - TAO_Notify_Proxy::initialize (topology_parent ACE_ENV_ARG_PARAMETER); + ACE_ASSERT( this->supplier_admin_.get() == 0 ); - this->supplier_admin_ = dynamic_cast<TAO_Notify_SupplierAdmin *> (topology_parent); - ACE_ASSERT(this->supplier_admin_ != 0); + TAO_Notify_Proxy::initialize (topology_parent ACE_ENV_ARG_PARAMETER); - this->supplier_admin_->_incr_refcnt (); + this->supplier_admin_.reset (dynamic_cast<TAO_Notify_SupplierAdmin *>(topology_parent)); + ACE_ASSERT (this->supplier_admin_.get() != 0); const CosNotification::QoSProperties &default_ps_qos = TAO_Notify_PROPERTIES::instance ()->default_proxy_consumer_qos_properties (); @@ -66,52 +64,45 @@ TAO_Notify_ProxyConsumer::connect (TAO_Notify_Supplier *supplier ACE_ENV_ARG_DEC , CosEventChannelAdmin::AlreadyConnected )) { - TAO_Notify_Atomic_Property_Long& supplier_count = this->admin_properties_->suppliers (); - const TAO_Notify_Property_Long& max_suppliers = this->admin_properties_->max_suppliers (); + // Adopt the supplier + ACE_Auto_Ptr< TAO_Notify_Supplier > auto_supplier (supplier); - if (max_suppliers != 0 && - supplier_count >= max_suppliers.value ()) + TAO_Notify_Atomic_Property_Long& supplier_count = this->admin_properties().suppliers (); + const TAO_Notify_Property_Long& max_suppliers = this->admin_properties().max_suppliers (); + + if (max_suppliers != 0 && supplier_count >= max_suppliers.value ()) + { ACE_THROW (CORBA::IMP_LIMIT ()); // we've reached the limit of suppliers connected. + } { ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); ACE_CHECK; - TAO_Notify_Supplier* deleted_supplier = 0; - if (this->is_connected ()) + // if supplier is set and reconnect not allowed we get out. + if (this->is_connected () && TAO_Notify_PROPERTIES::instance()->allow_reconnect() == false) { - if (TAO_Notify_PROPERTIES::instance()->allow_reconnect()) - { - deleted_supplier = this->supplier_; - } - else - { - supplier->release (); ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); } - } - this->supplier_ = supplier; + // Adopt the supplier + this->supplier_ = auto_supplier; this->supplier_admin_->subscribed_types (this->subscribed_types_ ACE_ENV_ARG_PARAMETER); // get the parents subscribed types. ACE_CHECK; - - if (deleted_supplier != 0) - { - deleted_supplier->_decr_refcnt(); } - } // Inform QoS values. - supplier_->qos_changed (this->qos_properties_); + ACE_ASSERT (this->supplier_.get() != 0); + this->supplier_->qos_changed (this->qos_properties_); TAO_Notify_EventTypeSeq removed; - this->event_manager_->offer_change (this, this->subscribed_types_, removed ACE_ENV_ARG_PARAMETER); + this->event_manager().offer_change (this, this->subscribed_types_, removed ACE_ENV_ARG_PARAMETER); ACE_CHECK; - this->event_manager_->connect (this ACE_ENV_ARG_PARAMETER); + this->event_manager().connect (this ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Increment the global supplier count @@ -122,8 +113,8 @@ TAO_Notify_ProxyConsumer::push_i (TAO_Notify_Event * event ACE_ENV_ARG_DECL) { if (this->supports_reliable_events ()) { - TAO_Notify_Event_var pevent; - event->queueable_copy (pevent ACE_ENV_ARG_PARAMETER); + TAO_Notify_Event::Ptr pevent ( + event->queueable_copy (ACE_ENV_SINGLE_ARG_PARAMETER) ); ACE_CHECK; TAO_Notify::Routing_Slip_Ptr routing_slip = TAO_Notify::Routing_Slip::create (pevent ACE_ENV_ARG_PARAMETER); @@ -137,7 +128,7 @@ TAO_Notify_ProxyConsumer::push_i (TAO_Notify_Event * event ACE_ENV_ARG_DECL) else { TAO_Notify_Method_Request_Lookup_No_Copy request (event, this); - this->worker_task ()->execute (request ACE_ENV_ARG_PARAMETER); + this->execute_task (request ACE_ENV_ARG_PARAMETER); ACE_CHECK; } } @@ -163,14 +154,14 @@ TAO_Notify_ProxyConsumer::disconnect (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_EventTypeSeq added; - event_manager_->offer_change (this, added, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + event_manager().offer_change (this, added, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); ACE_CHECK; - this->event_manager_->disconnect (this ACE_ENV_ARG_PARAMETER); + this->event_manager().disconnect (this ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Decrement the global supplier count - this->admin_properties_->suppliers ()--; + this->admin_properties().suppliers ()--; } int @@ -184,9 +175,10 @@ TAO_Notify_ProxyConsumer::shutdown (ACE_ENV_SINGLE_ARG_DECL) this->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (1); - if (this->supplier_ != 0) + if (this->supplier_.get() != 0) + { this->supplier_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); - + } return 0; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h index 862ffcddedd..f877c46e5f4 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h @@ -24,12 +24,10 @@ #include "orbsvcs/CosEventChannelAdminC.h" -#include "Refcountable_Guard_T.h" #include "Event.h" #include "Proxy.h" +#include "SupplierAdmin.h" - -class TAO_Notify_SupplierAdmin; class TAO_Notify_Supplier; /** @@ -41,11 +39,12 @@ class TAO_Notify_Supplier; class TAO_Notify_Serv_Export TAO_Notify_ProxyConsumer : public virtual TAO_Notify_Proxy { public: + typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_ProxyConsumer> Ptr; /// Constuctor TAO_Notify_ProxyConsumer (void); /// Destructor - ~TAO_Notify_ProxyConsumer (); + virtual ~TAO_Notify_ProxyConsumer (); /// init: overrides Topology_Object method virtual void init (TAO_Notify::Topology_Parent * topology_parent ACE_ENV_ARG_DECL); @@ -66,35 +65,34 @@ public: /// Destroy this object. virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); - /// Access our Peer. - virtual TAO_Notify_Peer* peer (void); - - /// Access the Supplier - TAO_Notify_Supplier* supplier (void); /// Return 1 if connected - int is_connected (void); + bool is_connected (void) const; /// The SA parent. - TAO_Notify_SupplierAdmin* supplier_admin (void); + TAO_Notify_SupplierAdmin& supplier_admin (void); protected: + /// Access the Supplier + TAO_Notify_Supplier* supplier (void); + /// Accept an event from the Supplier void push_i (TAO_Notify_Event * event ACE_ENV_ARG_DECL); +private: /// Is this part of a reliable channel bool supports_reliable_events () const; -protected: ///= Data Members. /// The SA parent. - TAO_Notify_SupplierAdmin* supplier_admin_; + TAO_Notify_SupplierAdmin::Ptr supplier_admin_; /// The Supplier that we're connect to. - TAO_Notify_Supplier* supplier_; -}; + ACE_Auto_Ptr<TAO_Notify_Supplier> supplier_; -typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_ProxyConsumer> TAO_Notify_ProxyConsumer_Guard; + /// Access our Peer. + virtual TAO_Notify_Peer* peer (void); +}; #if defined (__ACE_INLINE__) #include "ProxyConsumer.inl" diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl index 14843a741a0..4ad429ba0e5 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl @@ -1,19 +1,20 @@ // $Id$ -ACE_INLINE int -TAO_Notify_ProxyConsumer::is_connected (void) +ACE_INLINE bool +TAO_Notify_ProxyConsumer::is_connected (void) const { - return supplier_ == 0 ? 0 : 1; + return (this->supplier_.get() != 0); } ACE_INLINE TAO_Notify_Supplier* TAO_Notify_ProxyConsumer::supplier (void) { - return this->supplier_; + return this->supplier_.get(); } -ACE_INLINE TAO_Notify_SupplierAdmin* +ACE_INLINE TAO_Notify_SupplierAdmin& TAO_Notify_ProxyConsumer::supplier_admin (void) { - return this->supplier_admin_; + ACE_ASSERT( this->supplier_admin_.get() != 0 ); + return *this->supplier_admin_; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp index b5da6701dc9..2f836c0302a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp @@ -36,7 +36,7 @@ TAO_Notify_ProxyConsumer_T<SERVANT_TYPE>::MyAdmin (ACE_ENV_SINGLE_ARG_DECL) { CosNotifyChannelAdmin::SupplierAdmin_var ret; - CORBA::Object_var object = this->supplier_admin_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + CORBA::Object_var object = this->supplier_admin().ref (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (ret._retn ()); ret = CosNotifyChannelAdmin::SupplierAdmin::_narrow (object.in () ACE_ENV_ARG_PARAMETER); @@ -62,7 +62,7 @@ TAO_Notify_ProxyConsumer_T<SERVANT_TYPE>::offer_change (const CosNotification::E this->subscribed_types_.add_and_remove (seq_added, seq_removed); } - this->event_manager_->offer_change (this, seq_added, seq_removed ACE_ENV_ARG_PARAMETER); + this->event_manager().offer_change (this, seq_added, seq_removed ACE_ENV_ARG_PARAMETER); } template <class SERVANT_TYPE> CosNotification::EventTypeSeq* @@ -71,7 +71,7 @@ TAO_Notify_ProxyConsumer_T<SERVANT_TYPE>::obtain_subscription_types (CosNotifyCh CORBA::SystemException )) { - return this->obtain_types (mode, this->event_manager_->subscription_types () ACE_ENV_ARG_PARAMETER); + return this->obtain_types (mode, this->event_manager().subscription_types () ACE_ENV_ARG_PARAMETER); } #endif /* TAO_Notify_PROXYCONSUMER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp index 2b87323ca46..cd08b686721 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp @@ -19,23 +19,21 @@ ACE_RCSID(RT_Notify, TAO_Notify_ProxySupplier, "$Id$") TAO_Notify_ProxySupplier::TAO_Notify_ProxySupplier (void) : consumer_admin_ (0) - , consumer_ (0) { } TAO_Notify_ProxySupplier::~TAO_Notify_ProxySupplier () { - this->consumer_admin_->_decr_refcnt (); } void TAO_Notify_ProxySupplier::init (TAO_Notify_ConsumerAdmin* consumer_admin ACE_ENV_ARG_DECL) { - TAO_Notify_Proxy::initialize (consumer_admin ACE_ENV_ARG_PARAMETER); + ACE_ASSERT (consumer_admin != 0 && this->consumer_admin_.get() == 0); - this->consumer_admin_ = consumer_admin; + TAO_Notify_Proxy::initialize (consumer_admin ACE_ENV_ARG_PARAMETER); - this->consumer_admin_->_incr_refcnt (); + this->consumer_admin_.reset (consumer_admin); const CosNotification::QoSProperties &default_ps_qos = TAO_Notify_PROPERTIES::instance ()->default_proxy_supplier_qos_properties (); @@ -56,50 +54,44 @@ TAO_Notify_ProxySupplier::connect (TAO_Notify_Consumer *consumer ACE_ENV_ARG_DEC , CosEventChannelAdmin::AlreadyConnected )) { - TAO_Notify_Atomic_Property_Long& consumer_count = this->admin_properties_->consumers (); - const TAO_Notify_Property_Long& max_consumers = this->admin_properties_->max_consumers (); + // Adopt the consumer + ACE_Auto_Ptr< TAO_Notify_Consumer > auto_consumer (consumer); + + TAO_Notify_Atomic_Property_Long& consumer_count = this->admin_properties().consumers (); + const TAO_Notify_Property_Long& max_consumers = this->admin_properties().max_consumers (); - if (max_consumers != 0 && - consumer_count >= max_consumers.value ()) + if (max_consumers != 0 && consumer_count >= max_consumers.value ()) + { ACE_THROW (CORBA::IMP_LIMIT ()); // we've reached the limit of consumers connected. + } { ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); ACE_CHECK; - TAO_Notify_Consumer * deleted_consumer = 0; - if (this->is_connected ()) + // if consumer is set and reconnect not allowed we get out. + if (this->is_connected () && TAO_Notify_PROPERTIES::instance()->allow_reconnect() == false) { - if (TAO_Notify_PROPERTIES::instance()->allow_reconnect()) - { - deleted_consumer = this->consumer_; - } - else - { - consumer->release (); ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); } - } - consumer_ = consumer; + // Adopt the consumer + this->consumer_ = auto_consumer; this->consumer_admin_->subscribed_types (this->subscribed_types_ ACE_ENV_ARG_PARAMETER); // get the parents subscribed types. ACE_CHECK; - if (deleted_consumer != 0) - { - deleted_consumer->_decr_refcnt(); - } } // Inform QoS values. - consumer_->qos_changed (this->qos_properties_); + ACE_ASSERT (this->consumer_.get() != 0); + this->consumer_->qos_changed (this->qos_properties_); TAO_Notify_EventTypeSeq removed; - this->event_manager_->subscription_change (this, this->subscribed_types_, removed ACE_ENV_ARG_PARAMETER); + this->event_manager().subscription_change (this, this->subscribed_types_, removed ACE_ENV_ARG_PARAMETER); - this->event_manager_->connect (this ACE_ENV_ARG_PARAMETER); + this->event_manager().connect (this ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Increment the global consumer count @@ -111,14 +103,14 @@ TAO_Notify_ProxySupplier::disconnect (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_EventTypeSeq added; - this->event_manager_->subscription_change (this, added, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + this->event_manager().subscription_change (this, added, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); ACE_CHECK; - this->event_manager_->disconnect (this ACE_ENV_ARG_PARAMETER); + this->event_manager().disconnect (this ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Decrement the global consumer count - this->admin_properties_->consumers ()--; + this->admin_properties().consumers ()--; } int @@ -132,9 +124,10 @@ TAO_Notify_ProxySupplier::shutdown (ACE_ENV_SINGLE_ARG_DECL) this->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (1); - if (this->consumer_ != 0) + if (this->consumer_.get() != 0) + { this->consumer_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); - + } return 0; } @@ -151,31 +144,14 @@ TAO_Notify_ProxySupplier::destroy (ACE_ENV_SINGLE_ARG_DECL) } void -TAO_Notify_ProxySupplier::deliver (TAO_Notify_Method_Request & request ACE_ENV_ARG_DECL) +TAO_Notify_ProxySupplier::deliver (TAO_Notify_Method_Request_Dispatch_No_Copy & request ACE_ENV_ARG_DECL) { - this->worker_task ()->execute (request ACE_ENV_ARG_PARAMETER); + this->execute_task (request ACE_ENV_ARG_PARAMETER); } void TAO_Notify_ProxySupplier::qos_changed (const TAO_Notify_QoSProperties& qos_properties) { - TAO_Notify_Property_Long mepc_qos (CosNotification::MaxEventsPerConsumer); - - if (mepc_qos.set (qos_properties) != -1) - { - // Does the Proxy own the Worker Task? - if (own_worker_task_) - { - TAO_Notify_Buffering_Strategy* bs = this->worker_task_->buffering_strategy (); - - // Apply this QoS to the Proxy's Buffering Strategy. - if (bs) - { - bs->max_local_queue_length (mepc_qos.value ()); - } - } - } - TAO_Notify_Proxy::qos_changed (qos_properties); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h index a099204f539..31615beec88 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h @@ -21,12 +21,12 @@ #include "Event.h" #include "Proxy.h" -#include "Refcountable_Guard_T.h" +#include "ConsumerAdmin.h" + #include "orbsvcs/CosEventChannelAdminC.h" class TAO_Notify_Consumer; -class TAO_Notify_ConsumerAdmin; -class TAO_Notify_Method_Request; +class TAO_Notify_Method_Request_Dispatch_No_Copy; /** * @class TAO_Notify_ProxySupplier * @@ -38,6 +38,7 @@ class TAO_Notify_Serv_Export TAO_Notify_ProxySupplier : public virtual TAO_Notif friend class TAO_Notify_Consumer; public: + typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_ProxySupplier> Ptr; /// Constuctor TAO_Notify_ProxySupplier (void); @@ -57,7 +58,7 @@ public: void disconnect (ACE_ENV_SINGLE_ARG_DECL); /// Dispatch Event to consumer - virtual void deliver (TAO_Notify_Method_Request & request ACE_ENV_ARG_DECL); + virtual void deliver (TAO_Notify_Method_Request_Dispatch_No_Copy & request ACE_ENV_ARG_DECL); /// Override TAO_Notify_Container_T::shutdown method virtual int shutdown (ACE_ENV_SINGLE_ARG_DECL); @@ -68,30 +69,26 @@ public: /// Override, TAO_Notify_Proxy::qos_changed to apply MaxEventssPerConsumer QoS. virtual void qos_changed (const TAO_Notify_QoSProperties& qos_properties); - /// Access our Peer. - virtual TAO_Notify_Peer* peer (void); + /// Returns true if connected + bool is_connected (void) const; /// Access the Consumer TAO_Notify_Consumer* consumer (void); - /// Return 1 if connected - int is_connected (void); - /// The CA parent. - TAO_Notify_ConsumerAdmin* consumer_admin (void); - -// const char * get_proxy_type_name (void) const; -protected: + TAO_Notify_ConsumerAdmin& consumer_admin (void); +private: ///= Data Members. /// The CA parent. - TAO_Notify_ConsumerAdmin* consumer_admin_; + TAO_Notify_ConsumerAdmin::Ptr consumer_admin_; /// The Consumer that we're connect to. - TAO_Notify_Consumer* consumer_; -}; + ACE_Auto_Ptr<TAO_Notify_Consumer> consumer_; -typedef TAO_Notify_Refcountable_Guard_T<TAO_Notify_ProxySupplier> TAO_Notify_ProxySupplier_Guard; + /// Access our Peer. + virtual TAO_Notify_Peer* peer (void); +}; #if defined (__ACE_INLINE__) #include "ProxySupplier.inl" diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl index 3a77cad7734..46b16302e2e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl @@ -1,19 +1,20 @@ // $Id$ -ACE_INLINE int -TAO_Notify_ProxySupplier::is_connected (void) +ACE_INLINE bool +TAO_Notify_ProxySupplier::is_connected (void) const { - return consumer_ == 0 ? 0 : 1; + return ( this->consumer_.get() != 0 ); } ACE_INLINE TAO_Notify_Consumer* TAO_Notify_ProxySupplier::consumer (void) { - return this->consumer_; + return this->consumer_.get(); } -ACE_INLINE TAO_Notify_ConsumerAdmin* +ACE_INLINE TAO_Notify_ConsumerAdmin& TAO_Notify_ProxySupplier::consumer_admin (void) { - return this->consumer_admin_; + ACE_ASSERT( this->consumer_admin_.get() != 0 ); + return *this->consumer_admin_; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp index 23dad7b45b2..c926f4f5824 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp @@ -45,7 +45,7 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::forward_structured (const CosNotificat TAO_Notify_Method_Request_Dispatch_No_Copy request (&event, this, 1); - this->worker_task ()->execute (request ACE_ENV_ARG_PARAMETER); + this->execute_task (request ACE_ENV_ARG_PARAMETER); } template <class SERVANT_TYPE> void @@ -58,7 +58,7 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::forward_structured_no_filtering (const TAO_Notify_Method_Request_Dispatch_No_Copy request (&event, this, 0); - this->worker_task ()->execute (request ACE_ENV_ARG_PARAMETER); + this->execute_task (request ACE_ENV_ARG_PARAMETER); } template <class SERVANT_TYPE> void @@ -71,7 +71,7 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::forward_any (const CORBA::Any & any AC TAO_Notify_Method_Request_Dispatch_No_Copy request (&event, this, 1); - this->worker_task ()->execute (request ACE_ENV_ARG_PARAMETER); + this->execute_task (request ACE_ENV_ARG_PARAMETER); } template <class SERVANT_TYPE> void @@ -84,7 +84,7 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::forward_any_no_filtering (const CORBA: TAO_Notify_Method_Request_Dispatch_No_Copy request (&event, this, 0); - this->worker_task ()->execute (request ACE_ENV_ARG_PARAMETER); + this->execute_task (request ACE_ENV_ARG_PARAMETER); } template <class SERVANT_TYPE> CosNotification::EventTypeSeq* @@ -93,7 +93,7 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::obtain_offered_types (CosNotifyChannel CORBA::SystemException )) { - return this->obtain_types (mode, this->event_manager_->offered_types () ACE_ENV_ARG_PARAMETER); + return this->obtain_types (mode, this->event_manager().offered_types () ACE_ENV_ARG_PARAMETER); } template <class SERVANT_TYPE> void @@ -114,7 +114,7 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::subscription_change (const CosNotifica this->subscribed_types_.add_and_remove (seq_added, seq_removed); } - this->event_manager_->subscription_change (this, seq_added, seq_removed ACE_ENV_ARG_PARAMETER); + this->event_manager().subscription_change (this, seq_added, seq_removed ACE_ENV_ARG_PARAMETER); } template <class SERVANT_TYPE> void @@ -131,11 +131,11 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::suspend_connection (ACE_ENV_SINGLE_ARG if (this->is_connected () == 0) ACE_THROW (CosNotifyChannelAdmin::NotConnected ()); - if (this->consumer_->is_suspended () == 1) + if (this->consumer()->is_suspended () == 1) ACE_THROW (CosNotifyChannelAdmin::ConnectionAlreadyInactive ()); } - this->consumer_->suspend (ACE_ENV_SINGLE_ARG_PARAMETER); + this->consumer()->suspend (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; @@ -155,11 +155,11 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::resume_connection (ACE_ENV_SINGLE_ARG_ if (this->is_connected () == 0) ACE_THROW (CosNotifyChannelAdmin::NotConnected ()); - if (this->consumer_->is_suspended () == 0) + if (this->consumer()->is_suspended () == 0) ACE_THROW (CosNotifyChannelAdmin::ConnectionAlreadyActive ()); } - this->consumer_->resume (ACE_ENV_SINGLE_ARG_PARAMETER); + this->consumer()->resume (ACE_ENV_SINGLE_ARG_PARAMETER); } template <class SERVANT_TYPE> CosNotifyChannelAdmin::ConsumerAdmin_ptr @@ -170,7 +170,7 @@ TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::MyAdmin (ACE_ENV_SINGLE_ARG_DECL) { CosNotifyChannelAdmin::ConsumerAdmin_var ret; - CORBA::Object_var object = this->consumer_admin_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + CORBA::Object_var object = this->consumer_admin().ref (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (ret._retn ()); ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (object.in () ACE_ENV_ARG_PARAMETER); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp index 50cf9e72f0b..4858f2da0c3 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp @@ -10,6 +10,8 @@ ACE_RCSID(Notify, TAO_Notify_Proxy_T, "$Id$") template <class SERVANT_TYPE> TAO_Notify_Proxy_T<SERVANT_TYPE>::TAO_Notify_Proxy_T (void) { + // Any object that is used by the POA gets a reference count of 1 at construction + this->_incr_refcnt(); } template <class SERVANT_TYPE> diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp index 7af2da443ab..28767124b86 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp @@ -9,20 +9,22 @@ ACE_RCSID(Notify, TAO_Notify_QoSProperties, "$Id$") #include "Property.h" - - +#include "Notify_Extensions.h" TAO_Notify_QoSProperties::TAO_Notify_QoSProperties (void) - : event_reliability_(CosNotification::EventReliability) - , connection_reliability_(CosNotification::ConnectionReliability) - , priority_ (CosNotification::Priority) - , timeout_ (CosNotification::Timeout) - , stop_time_supported_ (CosNotification::StopTimeSupported) - , maximum_batch_size_ (CosNotification::MaximumBatchSize) - , max_events_per_consumer_ (CosNotification::MaxEventsPerConsumer) - , pacing_interval_ (CosNotification::PacingInterval) - , thread_pool_ (NotifyExt::ThreadPool) - , thread_pool_lane_ (NotifyExt::ThreadPoolLanes) +: event_reliability_(CosNotification::EventReliability) +, connection_reliability_(CosNotification::ConnectionReliability) +, priority_ (CosNotification::Priority) +, timeout_ (CosNotification::Timeout) +, stop_time_supported_ (CosNotification::StopTimeSupported) +, maximum_batch_size_ (CosNotification::MaximumBatchSize) +, pacing_interval_ (CosNotification::PacingInterval) +, max_events_per_consumer_ (CosNotification::MaxEventsPerConsumer) +, discard_policy_ (CosNotification::DiscardPolicy) +, order_policy_ (CosNotification::OrderPolicy) +, thread_pool_ (NotifyExt::ThreadPool) +, thread_pool_lane_ (NotifyExt::ThreadPoolLanes) +, blocking_policy_(TAO_Notify_Extensions::BlockingPolicy) { unsupported_[0] = CosNotification::StartTimeSupported; } @@ -93,6 +95,19 @@ TAO_Notify_QoSProperties::init () a <<= this->max_events_per_consumer_.value(); this->add(this->max_events_per_consumer_.name(), a); } + if (this->discard_policy_.is_valid()) + { + CORBA::Any a; + a <<= this->discard_policy_.value(); + this->add(this->discard_policy_.name(), a); + } + if (this->order_policy_.is_valid()) + { + CORBA::Any a; + a <<= this->order_policy_.value(); + this->add(this->order_policy_.name(), a); + } + if (this->thread_pool_.is_valid()) { CORBA::Any a; @@ -105,6 +120,12 @@ TAO_Notify_QoSProperties::init () a <<= this->thread_pool_lane_.value(); this->add(this->thread_pool_lane_.name(), a); } + if (this->blocking_policy_.is_valid()) + { + CORBA::Any a; + a <<= this->blocking_policy_.value(); + this->add(this->blocking_policy_.name(), a); + } } int @@ -132,7 +153,6 @@ TAO_Notify_QoSProperties::init (const CosNotification::PropertySeq& prop_seq, Co if (prop_seq.length () > 0) { - // Now, init the supported properties this->event_reliability_.set (*this); this->connection_reliability_.set (*this); this->priority_.set (*this); @@ -140,8 +160,13 @@ TAO_Notify_QoSProperties::init (const CosNotification::PropertySeq& prop_seq, Co this->stop_time_supported_.set (*this); this->maximum_batch_size_.set (*this); this->pacing_interval_.set (*this); + this->max_events_per_consumer_.set (*this); + this->discard_policy_.set (*this); + this->order_policy_.set (*this); + this->thread_pool_.set (*this); this->thread_pool_lane_.set (*this); + this->blocking_policy_.set (*this); } return err_index == -1 ? 0 : 1; @@ -157,6 +182,11 @@ TAO_Notify_QoSProperties::copy (TAO_Notify_QoSProperties& qos_properties) qos_properties.stop_time_supported_ = this->stop_time_supported_; qos_properties.maximum_batch_size_ = this->maximum_batch_size_; qos_properties.pacing_interval_ = this->pacing_interval_; + qos_properties.max_events_per_consumer_ = this->max_events_per_consumer_; + qos_properties.discard_policy_ = this->discard_policy_; + qos_properties.order_policy_ = this->order_policy_; + + qos_properties.blocking_policy_ = this->blocking_policy_; PROPERTY_MAP::ITERATOR iter (this->property_map_); PROPERTY_MAP::ENTRY *entry; diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h index 91572274252..3f075a1dcbc 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h @@ -38,7 +38,7 @@ public: TAO_Notify_QoSProperties (void); /// Destructor - ~TAO_Notify_QoSProperties (); + virtual ~TAO_Notify_QoSProperties (); /// Return 0 on success, 1 if unsupported properties were detected and -1 on error. int init (const CosNotification::PropertySeq& prop_seq, CosNotification::PropertyErrorSeq& err_seq); @@ -53,25 +53,20 @@ public: int transfer (TAO_Notify_QoSProperties& qos_properties); ///= Accessors - /// ThreadPool const TAO_Notify_Property_ThreadPool& thread_pool (void) const; - - /// ThreadPoolLane const TAO_Notify_Property_ThreadPoolLanes& thread_pool_lane (void) const; - /// Maximum Batch Size - const TAO_Notify_Property_Long& maximum_batch_size (void) const; - - /// Pacing Interval - const TAO_Notify_Property_Time& pacing_interval (void) const; - ///= Accessors - const TAO_Notify_Property_Short& event_reliability (void) const; const TAO_Notify_Property_Short& connection_reliability (void) const; const TAO_Notify_Property_Short& priority (void) const; const TAO_Notify_Property_Time& timeout (void) const; const TAO_Notify_Property_Boolean& stop_time_supported (void) const; + const TAO_Notify_Property_Long& maximum_batch_size (void) const; + const TAO_Notify_Property_Time& pacing_interval (void) const; const TAO_Notify_Property_Long& max_events_per_consumer (void) const; + const TAO_Notify_Property_Short& discard_policy(void) const; + const TAO_Notify_Property_Short& order_policy(void) const; + const TAO_Notify_Property_Time& blocking_policy(void) const; // The non-const accessors are used during topology load TAO_Notify_Property_Short& event_reliability (void); @@ -82,6 +77,9 @@ public: TAO_Notify_Property_Long& maximum_batch_size (void); TAO_Notify_Property_Time& pacing_interval (void); TAO_Notify_Property_Long& max_events_per_consumer (void); + TAO_Notify_Property_Short& discard_policy(void); + TAO_Notify_Property_Short& order_policy(void); + TAO_Notify_Property_Time& blocking_policy(void); protected: /// Return 1 if <value> is unsupported. @@ -92,37 +90,22 @@ protected: ///= Unsupported Properties. ACE_CString unsupported_[UNSUPPORTED_PROPERTY_COUNT]; - ///= Supported properties - - /// Event Reliability + ///= Supported standard properties TAO_Notify_Property_Short event_reliability_; - - /// Connection Reliability TAO_Notify_Property_Short connection_reliability_; - - /// Priority TAO_Notify_Property_Short priority_; - - /// Timeout TAO_Notify_Property_Time timeout_; - - /// Stop Time Supported TAO_Notify_Property_Boolean stop_time_supported_; - - /// Maximum Batch Size TAO_Notify_Property_Long maximum_batch_size_; - - /// Maximum Events (queue length) Per Consumer - TAO_Notify_Property_Long max_events_per_consumer_; - - /// Pacing Interval TAO_Notify_Property_Time pacing_interval_; + TAO_Notify_Property_Long max_events_per_consumer_; + TAO_Notify_Property_Short discard_policy_; + TAO_Notify_Property_Short order_policy_; - /// ThreadPool Params. + /// TAO Extensions TAO_Notify_Property_ThreadPool thread_pool_; - - /// ThreadPoolLane Params. TAO_Notify_Property_ThreadPoolLanes thread_pool_lane_; + TAO_Notify_Property_Time blocking_policy_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl index 14aab6a7866..cc822edf7e4 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl @@ -35,6 +35,18 @@ TAO_Notify_QoSProperties::stop_time_supported(void) const return this->stop_time_supported_; } +ACE_INLINE const TAO_Notify_Property_Long& +TAO_Notify_QoSProperties::maximum_batch_size (void) const +{ + return this->maximum_batch_size_; +} + +ACE_INLINE const TAO_Notify_Property_Time& +TAO_Notify_QoSProperties::pacing_interval (void) const +{ + return this->pacing_interval_; +} + ACE_INLINE const TAO_Notify_Property_Long& TAO_Notify_QoSProperties::max_events_per_consumer (void) const @@ -42,6 +54,20 @@ TAO_Notify_QoSProperties::max_events_per_consumer (void) const return this->max_events_per_consumer_; } +ACE_INLINE +const TAO_Notify_Property_Short& +TAO_Notify_QoSProperties::discard_policy(void) const +{ + return this->discard_policy_; +} + +ACE_INLINE +const TAO_Notify_Property_Short& +TAO_Notify_QoSProperties::order_policy(void) const +{ + return this->order_policy_; +} + ACE_INLINE const TAO_Notify_Property_ThreadPool& TAO_Notify_QoSProperties::thread_pool (void) const { @@ -54,17 +80,14 @@ TAO_Notify_QoSProperties::thread_pool_lane (void) const return this->thread_pool_lane_; } -ACE_INLINE const TAO_Notify_Property_Long& -TAO_Notify_QoSProperties::maximum_batch_size (void) const +ACE_INLINE +const TAO_Notify_Property_Time& +TAO_Notify_QoSProperties::blocking_policy(void) const { - return this->maximum_batch_size_; + return this->blocking_policy_; } -ACE_INLINE const TAO_Notify_Property_Time& -TAO_Notify_QoSProperties::pacing_interval (void) const -{ - return this->pacing_interval_; -} +/////////////////////////////////////////////////////////////////////////////// ACE_INLINE TAO_Notify_Property_Short& @@ -101,6 +124,17 @@ TAO_Notify_QoSProperties::stop_time_supported(void) return this->stop_time_supported_; } +ACE_INLINE TAO_Notify_Property_Long& +TAO_Notify_QoSProperties::maximum_batch_size (void) +{ + return this->maximum_batch_size_; +} + +ACE_INLINE TAO_Notify_Property_Time& +TAO_Notify_QoSProperties::pacing_interval (void) +{ + return this->pacing_interval_; +} ACE_INLINE TAO_Notify_Property_Long& TAO_Notify_QoSProperties::max_events_per_consumer (void) @@ -108,15 +142,16 @@ TAO_Notify_QoSProperties::max_events_per_consumer (void) return this->max_events_per_consumer_; } - -ACE_INLINE TAO_Notify_Property_Long& -TAO_Notify_QoSProperties::maximum_batch_size (void) +ACE_INLINE +TAO_Notify_Property_Short& +TAO_Notify_QoSProperties::discard_policy(void) { - return this->maximum_batch_size_; + return this->discard_policy_; } -ACE_INLINE TAO_Notify_Property_Time& -TAO_Notify_QoSProperties::pacing_interval (void) +ACE_INLINE +TAO_Notify_Property_Short& +TAO_Notify_QoSProperties::order_policy(void) { - return this->pacing_interval_; + return this->order_policy_; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/README b/TAO/orbsvcs/orbsvcs/Notify/README index 1f7797efc39..454dc9367b7 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/README +++ b/TAO/orbsvcs/orbsvcs/Notify/README @@ -14,13 +14,13 @@ way push to consumers. These are the points at which the Event Channel has to interact with remote objects whose implementation is unknown to the Event Channel. e.g. if a consumer decided to execute a tight loop in its push method, it would block the entire event channel if it was -single threaded. By depllying a thread pool to perform dispatching +single threaded. By deploying a thread pool to perform dispatching events to consumers - we can alleviate this problem. [Also read the $TAO_ROOT/orbsvcs/Notify_Service/README for a proper description of how to specify these parameters.] --MTDispatching +-DispatchingThreads Consider a Notify service running with just one thread, namely the main. In this case when the event channel dispatches an event to a consumer (by calling its push method) all other consumers will be blocked, waiting for @@ -28,30 +28,11 @@ their push methods to be invoked. To decouple the consumers from one another we can deploy dispatching threads using this option. --MTListenerEval -In the design of the Notify, all proxy suppliers are modelled as -"listeners". i,e. they listen for events from the event manager. -The MListenerEval option allows us to deploy a thread pool per listener -for filter evaluation. So, if you have big or remote filters associated -with your proxy suppliers you would want to set this option. again the -intent is to decouple the processing time for filter evaluation from rest -of the activities in the event channel. -as it stands now, if you were to set this option, there would be a thread -pool for *every* proxy supplier in the EC. what i would have liked to do -is to be able to set this option as a QoS property so that the thread pool -is set programatically at run time. - - --MTSourceEval -Similarly, this option is used to deploy a thread pool per proxy consumer -to evaluate filters attached with it. The proxy consumers are modelled as -event sources - supplying events to the event manager. again this will set -a thread pool per proxy consumer. - --MTLookup -This option allows us to set a common thread pool for *all* proxy -suppliers (versus a dedicated thread pool for each proxy supplier via the --MTDispatching option). +-ListenerThreads +Deploys a thread pool after event receipt from the supplier. All subsequent +notification channel processing can happen on this thread and the original +publishing push() can be ended. Separates server side processing of the +event from the supplier's publication. Usage: diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp b/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp index 3c9d6beb3a1..99000054e16 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Builder.cpp @@ -34,7 +34,7 @@ TAO_Notify_RT_Builder::apply_thread_pool_concurrency (TAO_Notify_Object& object CORBA::NO_MEMORY ()); ACE_CHECK; - auto_ptr<TAO_Notify_POA_Helper> auto_proxy_poa (proxy_poa); + ACE_Auto_Ptr<TAO_Notify_POA_Helper> auto_proxy_poa (proxy_poa); PortableServer::POA_var default_poa = TAO_Notify_PROPERTIES::instance ()->default_poa (); @@ -42,10 +42,7 @@ TAO_Notify_RT_Builder::apply_thread_pool_concurrency (TAO_Notify_Object& object ACE_CHECK; // Give ownership of proxy_poa - object.proxy_poa_own (proxy_poa); - - // release auto ref. - auto_proxy_poa.release (); + object.set_proxy_poa (auto_proxy_poa.release ()); } void @@ -60,7 +57,7 @@ TAO_Notify_RT_Builder::apply_lane_concurrency (TAO_Notify_Object& object CORBA::NO_MEMORY ()); ACE_CHECK; - auto_ptr<TAO_Notify_POA_Helper> auto_proxy_poa (proxy_poa); + ACE_Auto_Ptr<TAO_Notify_POA_Helper> auto_proxy_poa (proxy_poa); PortableServer::POA_var default_poa = TAO_Notify_PROPERTIES::instance ()->default_poa (); @@ -68,8 +65,6 @@ TAO_Notify_RT_Builder::apply_lane_concurrency (TAO_Notify_Object& object ACE_CHECK; // Give ownership of proxy_poa - object.proxy_poa_own (proxy_poa); + object.set_proxy_poa (auto_proxy_poa.release ()); - // release auto ref. - auto_proxy_poa.release (); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp index 9c1f31d8334..29d6ecce40d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.cpp @@ -18,14 +18,8 @@ TAO_RT_Notify_Service::~TAO_RT_Notify_Service () { } -int -TAO_RT_Notify_Service::init (int argc, char *argv[]) -{ - return TAO_CosNotify_Service::init (argc, argv); -} - void -TAO_RT_Notify_Service::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +TAO_RT_Notify_Service::init_service (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { ACE_DEBUG ((LM_DEBUG, "Loading the Real-Time Notification Service...\n")); @@ -69,31 +63,31 @@ TAO_RT_Notify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) properties->current (current.in ()); } -void -TAO_RT_Notify_Service::init_factory (ACE_ENV_SINGLE_ARG_DECL) +TAO_Notify_Factory* +TAO_RT_Notify_Service::create_factory (ACE_ENV_SINGLE_ARG_DECL) { - this->factory_ = ACE_Dynamic_Service<TAO_Notify_Factory>::instance ("TAO_Notify_Factory"); + TAO_Notify_Factory* factory = ACE_Dynamic_Service<TAO_Notify_Factory>::instance ("TAO_Notify_Factory"); - if (this->factory_ == 0) + if (factory == 0) { - ACE_NEW_THROW_EX (this->factory_, + ACE_NEW_THROW_EX (factory, TAO_Notify_RT_Factory (), CORBA::NO_MEMORY ()); ACE_CHECK; } - - TAO_Notify_PROPERTIES::instance()->factory (this->factory_); + return factory; } -void -TAO_RT_Notify_Service::init_builder (ACE_ENV_SINGLE_ARG_DECL) +TAO_Notify_Builder* +TAO_RT_Notify_Service::create_builder (ACE_ENV_SINGLE_ARG_DECL) { - ACE_NEW_THROW_EX (this->builder_, + TAO_Notify_Builder* builder = 0; + ACE_NEW_THROW_EX (builder, TAO_Notify_RT_Builder (), CORBA::NO_MEMORY ()); ACE_CHECK; - TAO_Notify_PROPERTIES::instance()->builder (this->builder_); + return builder; } ACE_FACTORY_DEFINE (TAO_RT_Notify,TAO_RT_Notify_Service) diff --git a/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h index 5531ba67246..abc89814126 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h +++ b/TAO/orbsvcs/orbsvcs/Notify/RT_Notify_Service.h @@ -36,21 +36,19 @@ public: /// Destructor ~TAO_RT_Notify_Service (); - /// Overload base virtual method to silence HPUX11 build warning. - virtual int init (int argc, char *argv[]); /// Init the service. - virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + virtual void init_service (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); protected: /// Init the data members virtual void init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); /// Create the Factory for RT Notify objects. - virtual void init_factory (ACE_ENV_SINGLE_ARG_DECL); + virtual TAO_Notify_Factory* create_factory (ACE_ENV_SINGLE_ARG_DECL); /// Creates the Builder for RT Notify objects. - virtual void init_builder (ACE_ENV_SINGLE_ARG_DECL); + virtual TAO_Notify_Builder* create_builder (ACE_ENV_SINGLE_ARG_DECL); }; ACE_FACTORY_DECLARE (TAO_RT_Notify,TAO_RT_Notify_Service) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Random_File.cpp b/TAO/orbsvcs/orbsvcs/Notify/Random_File.cpp index d51905fac35..acf3ce1d1d2 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Random_File.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Random_File.cpp @@ -45,7 +45,7 @@ Random_File::size() const } bool -Random_File::open(const char* filename, size_t block_size) +Random_File::open(const ACE_TCHAR* filename, size_t block_size) { ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, false); this->block_size_ = block_size; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Random_File.h b/TAO/orbsvcs/orbsvcs/Notify/Random_File.h index 833d5274114..a58e6f21e0e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Random_File.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Random_File.h @@ -47,7 +47,7 @@ public: ~Random_File(); /// Open a file with default permissions. - bool open(const char* filename, size_t block_size = 512); + bool open(const ACE_TCHAR* filename, size_t block_size = 512); /// Accessor for the block size. /// Note signed size_t is used to be compatible with diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp index 5485f75fd79..2b941299a9a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp @@ -20,17 +20,20 @@ TAO_Notify_Reactive_Task::~TAO_Notify_Reactive_Task () } void -TAO_Notify_Reactive_Task::init (TAO_Notify_AdminProperties_var& /*admin_properties*/ ACE_ENV_ARG_DECL) +TAO_Notify_Reactive_Task::init (ACE_ENV_ARG_DECL) { - ACE_NEW_THROW_EX (this->timer_, + ACE_ASSERT (this->timer_.get() == 0); + + TAO_Notify_Timer_Reactor* timer = 0; + ACE_NEW_THROW_EX (timer, TAO_Notify_Timer_Reactor (), CORBA::NO_MEMORY ()); + this->timer_.reset (timer); } void TAO_Notify_Reactive_Task::release (void) { - this->timer_->_decr_refcnt (); delete this; //TODO: Release via factory. } @@ -48,6 +51,5 @@ TAO_Notify_Reactive_Task::execute (TAO_Notify_Method_Request& method_request ACE TAO_Notify_Timer* TAO_Notify_Reactive_Task::timer (void) { - this->timer_->_incr_refcnt (); - return this->timer_; + return this->timer_.get(); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h index 4ef50649649..9b0f1381acf 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h @@ -22,8 +22,7 @@ #include "Worker_Task.h" #include "AdminProperties.h" - -class TAO_Notify_Timer_Reactor; +#include "Timer_Reactor.h" /** * @class TAO_Notify_Reactive_Task @@ -38,13 +37,11 @@ public: TAO_Notify_Reactive_Task (void); /// Destructor - ~TAO_Notify_Reactive_Task (); + virtual ~TAO_Notify_Reactive_Task (); - /// Release - virtual void release (void); /// Init the reactive task. - void init (TAO_Notify_AdminProperties_var& admin_properties ACE_ENV_ARG_DECL); + void init (ACE_ENV_ARG_DECL); /// Shutdown task virtual void shutdown (void); @@ -60,7 +57,10 @@ public: protected: /// The timer. - TAO_Notify_Timer_Reactor* timer_; + TAO_Notify_Timer_Reactor::Ptr timer_; +private: + /// Release + virtual void release (void); }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reconnection_Registry.h b/TAO/orbsvcs/orbsvcs/Notify/Reconnection_Registry.h index 69f5adaeaa9..7fd7c455014 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Reconnection_Registry.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Reconnection_Registry.h @@ -53,7 +53,7 @@ namespace TAO_Notify Reconnection_Registry (Topology_Parent & parent); /// Destructor - ~Reconnection_Registry (); + virtual ~Reconnection_Registry (); ////////////////////////// // During normal operation @@ -84,9 +84,9 @@ namespace TAO_Notify void send_reconnect (CosNotifyChannelAdmin::EventChannelFactory_ptr dest_factory ACE_ENV_ARG_DECL); + private: void release (void); - private: Reconnection_Registry_Type reconnection_registry_; ::NotifyExt::ReconnectionRegistry::ReconnectionID highest_id_; }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp index b0d869ce2e4..29f2061e5ba 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp @@ -8,41 +8,52 @@ ACE_RCSID(Notify, TAO_Notify_Refcountable, "$Id$") TAO_Notify_Refcountable::TAO_Notify_Refcountable (void) - :refcount_ (1) { } TAO_Notify_Refcountable::~TAO_Notify_Refcountable () { + Counter refcount = this->refcount_.value(); + if ( refcount != 0 ) + { + ACE_ERROR ((LM_ERROR,"ERROR: object:%x delete with non-zero refcount = %d\n", this, refcount )); + ACE_ASSERT( refcount == 0 ); + } } CORBA::ULong TAO_Notify_Refcountable::_incr_refcnt (void) { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); - + Counter refcount = ++this->refcount_; if (TAO_debug_level > 1 ) - ACE_DEBUG ((LM_DEBUG,"object:%x incr refcount = %d\n", this, refcount_+1 )); - - - return this->refcount_++; + { + ACE_DEBUG ((LM_DEBUG,"object:%x incr refcount = %d\n", this, refcount )); + } + return static_cast< CORBA::ULong >( refcount ); } CORBA::ULong TAO_Notify_Refcountable::_decr_refcnt (void) { - { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + Counter refcount = --this->refcount_; if (TAO_debug_level > 1 ) - ACE_DEBUG ((LM_DEBUG,"object:%x decr refcount = %d\n", this, refcount_-1 )); + { + ACE_DEBUG ((LM_DEBUG,"object:%x decr refcount = %d\n", this, refcount )); + } - this->refcount_--; - if (this->refcount_ != 0) - return this->refcount_; + // If error + if ( refcount < 0 ) + { + ACE_ERROR ((LM_ERROR,"ERROR: object:%x _decr_refcnt (%d < 0)\n", this, refcount )); + ACE_ASSERT( refcount >= 0 ); } + // Release if count is zero + else if ( refcount == 0 ) + { this->release (); + } - return 0; + return static_cast< CORBA::ULong >( refcount ); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h index c38000882d0..1d03486f3d1 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h @@ -15,6 +15,7 @@ #include /**/ "ace/pre.h" #include "notify_serv_export.h" +#include "Refcountable_Guard_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -24,36 +25,60 @@ #include "tao/Basic_Types.h" #include "ace/Synch_Traits.h" #include "ace/Thread_Mutex.h" +#include "ace/Atomic_Op.h" /** * @class TAO_Notify_Refcountable * * @brief Thread-safe refounting, calls the <release> method when refcount falls to 0. * + * The refcount is initialized to 0. When an instance of a derived class becomes owned + * by a managed pointer (Refcountable_Guard_T) the reference count becomes non-zero. + * A debug message is printed from the destructor if a refcounted is deleted with a + * non-zero refcount. + * + * Instances declared on the stack should always have a refcount of zero. + * + * A method that creates or simply returns an instance of Refcountable should not + * increment the reference count. It is the responsibility of the client to increment + * the reference count (take ownership or guard against deletion). The client cannot + * know if the method will or will not incr the refcount in its behalf. + * + * Use Refcountable_Guard_T or similar service to guarantee the exception safe direct + * pairing of increments and decrements. Avoid calling _incr_refcnt and _decr_refcnt. */ class TAO_Notify_Serv_Export TAO_Notify_Refcountable { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_Refcountable > Ptr; + typedef long Counter; + /// Constuctor TAO_Notify_Refcountable (void); /// Destructor + /// public for stack allocated instances virtual ~TAO_Notify_Refcountable (); - /// This method sigantures deliberately match the - /// RefCounting methods required for ESF Proxy + /// This method sigantures deliberately match the RefCounting methods required for ESF Proxy + /// Public for bridge implementations and various guard classes CORBA::ULong _incr_refcnt (void); CORBA::ULong _decr_refcnt (void); - /// The release method is called when the refcount reaches 0. - virtual void release (void) = 0; - protected: - /// The reference count. - CORBA::ULong refcount_; - /// The mutex to serialize access to state variables. TAO_SYNCH_MUTEX lock_; + + /// Accessor for debugging. +#ifdef _DEBUG + Counter refcount (void) const; +#endif + +private: + /// The release method is called when the refcount reaches 0. + virtual void release (void) = 0; + + ACE_Atomic_Op< TAO_SYNCH_MUTEX, Counter > refcount_; }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h index 77d1e2a5db1..555c302e40e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h @@ -24,6 +24,7 @@ * @class TAO_Notify_Refcountable_Guard_T * * @brief Increments the reference count in the constructor, the count is decremented in the destructor. + * See Refcountable.h for further notes on usage. * */ template <class T> @@ -31,30 +32,38 @@ class TAO_Notify_Refcountable_Guard_T { public: /// Constuctor - TAO_Notify_Refcountable_Guard_T (T* t = 0); + explicit TAO_Notify_Refcountable_Guard_T (T* t = 0); /// Copy constructor - TAO_Notify_Refcountable_Guard_T (const TAO_Notify_Refcountable_Guard_T<T> & rhs); + explicit TAO_Notify_Refcountable_Guard_T (const TAO_Notify_Refcountable_Guard_T<T>& rhs); /// Destructor ~TAO_Notify_Refcountable_Guard_T (); /// Redirection operator - T * get (void) const; + T* get (void) const; + + /// Boolean test + bool isSet (void) const; /// Redirection operator - T *operator-> (void) const; + T* operator -> (void) const; - T &operator *() const; + /// Dereference operator + T& operator * () const; - TAO_Notify_Refcountable_Guard_T<T> & operator = ( - const TAO_Notify_Refcountable_Guard_T<T> & rhs); + /// Reassignment + void reset (T* t = 0); + + // There is no logical release. Release could return an invalid object. + + /// Assignment + TAO_Notify_Refcountable_Guard_T<T>& operator = ( + const TAO_Notify_Refcountable_Guard_T<T>& rhs); private: - /// helper for exception safeness - /// @throws nothing - void swap (TAO_Notify_Refcountable_Guard_T & rhs); -private: + void swap( TAO_Notify_Refcountable_Guard_T<T>& rhs ); + T* t_; }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl index ad651ceb555..45a92e04262 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl @@ -6,49 +6,50 @@ template <class T> ACE_INLINE TAO_Notify_Refcountable_Guard_T<T>::TAO_Notify_Refcountable_Guard_T (T *t) : t_ (t) { - if (this->t_ != 0) - { - this->t_->_incr_refcnt (); - } + if ( this->t_ != static_cast< T* >( 0 ) ) this->t_->_incr_refcnt(); } template <class T> ACE_INLINE TAO_Notify_Refcountable_Guard_T<T>::TAO_Notify_Refcountable_Guard_T (const TAO_Notify_Refcountable_Guard_T<T> &rhs) : t_ (rhs.t_) { - if (this->t_ != 0) - { - this->t_->_incr_refcnt (); - } + if ( this->t_ != static_cast< T* >( 0 ) ) this->t_->_incr_refcnt(); } template <class T> ACE_INLINE TAO_Notify_Refcountable_Guard_T<T>::~TAO_Notify_Refcountable_Guard_T () { - if (this->t_ != 0) - { - this->t_->_decr_refcnt (); - } + if ( this->t_ != static_cast< T* >( 0 ) ) this->t_->_decr_refcnt(); } -template <class T> ACE_INLINE T* +template <class T> ACE_INLINE +T* TAO_Notify_Refcountable_Guard_T<T>::get (void) const { return this->t_; } -template <class T> ACE_INLINE T* +template <class T> ACE_INLINE +bool +TAO_Notify_Refcountable_Guard_T<T>::isSet (void) const +{ + return ( this->t_ != static_cast< T* >( 0 ) ); +} + + +template <class T> ACE_INLINE +T* TAO_Notify_Refcountable_Guard_T<T>::operator-> (void) const { - ACE_ASSERT (this->t_ != 0); + ACE_ASSERT ( this->t_ != static_cast< T* >( 0 ) ); return this->t_; } template <class T> ACE_INLINE T& -TAO_Notify_Refcountable_Guard_T<T>::operator *(void) const +TAO_Notify_Refcountable_Guard_T<T>::operator* (void) const { - ACE_ASSERT (this->t_ != 0); + ACE_ASSERT ( this->t_ != static_cast< T* >( 0 ) ); return *this->t_; } @@ -57,21 +58,28 @@ TAO_Notify_Refcountable_Guard_T<T> & TAO_Notify_Refcountable_Guard_T<T>::operator = ( const TAO_Notify_Refcountable_Guard_T<T> & rhs) { - // note exception safe assignment. see Sutter's "Exceptional C++" - // note it's worth the following optimization to avoid threadsafe increment/decrement refcounters - if (this->t_ != rhs.t_) { - TAO_Notify_Refcountable_Guard_T<T> temp(rhs.t_); - swap (temp); -} + reset( rhs.t_ ); return *this; } template <class T> ACE_INLINE void -TAO_Notify_Refcountable_Guard_T<T>::swap (TAO_Notify_Refcountable_Guard_T & rhs) +TAO_Notify_Refcountable_Guard_T<T>::reset (T* t) +{ + if (this->t_ != t) + { + TAO_Notify_Refcountable_Guard_T<T> temp( t ); + swap( temp ); + } +} + +template <class T> ACE_INLINE +void +TAO_Notify_Refcountable_Guard_T<T>::swap( + TAO_Notify_Refcountable_Guard_T<T>& rhs ) { - T* pt = rhs.t_; - rhs.t_ = this->t_; - this->t_ = pt; + T* temp = this->t_; + this->t_ = rhs.t_; + rhs.t_ = temp; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip.cpp b/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip.cpp index 2b3885daa56..5b30cd9527a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip.cpp @@ -52,7 +52,7 @@ size_t Routing_Slip::count_enter_deleting_ = 0; size_t Routing_Slip::count_enter_terminal_ = 0; Routing_Slip_Ptr -Routing_Slip::create (const TAO_Notify_Event_var& event ACE_ENV_ARG_DECL) +Routing_Slip::create (const TAO_Notify_Event::Ptr& event ACE_ENV_ARG_DECL) { Routing_Slip * prs; ACE_NEW_THROW_EX (prs, Routing_Slip (event), CORBA::NO_MEMORY ()); @@ -117,7 +117,7 @@ Routing_Slip::create ( if (rspm->reload (event_mb, rs_mb)) { TAO_InputCDR cdr_event (event_mb); - TAO_Notify_Event_Copy_var event (TAO_Notify_Event::unmarshal (cdr_event)); + TAO_Notify_Event::Ptr event (TAO_Notify_Event::unmarshal (cdr_event)); if (event.get () != 0) { result = create (event ACE_ENV_ARG_PARAMETER); @@ -167,7 +167,7 @@ Routing_Slip::set_rspm (Routing_Slip_Persistence_Manager * rspm) } Routing_Slip::Routing_Slip( - const TAO_Notify_Event_var& event) + const TAO_Notify_Event::Ptr& event) : is_safe_ (false) , until_safe_ (internals_) , this_ptr_ (0) @@ -211,7 +211,7 @@ Routing_Slip::create_persistence_manager() return this->rspm_ != 0; } -const TAO_Notify_Event_var & +const TAO_Notify_Event::Ptr & Routing_Slip::event () const { return this->event_; @@ -232,7 +232,7 @@ Routing_Slip::route (TAO_Notify_ProxyConsumer* pc, bool reliable_channel ACE_ENV { ACE_ASSERT(pc != 0); - TAO_Notify_Refcountable_Guard_T<TAO_Notify_ProxyConsumer> pcgrd(pc); + TAO_Notify_ProxyConsumer::Ptr pcgrd(pc); Routing_Slip_Guard guard (this->internals_); @@ -274,7 +274,7 @@ Routing_Slip::route (TAO_Notify_ProxyConsumer* pc, bool reliable_channel ACE_ENV } } guard.release (); - pc->worker_task()->execute (method ACE_ENV_ARG_PARAMETER); + pc->execute_task (method ACE_ENV_ARG_PARAMETER); } #if 0 // forward void @@ -283,7 +283,7 @@ Routing_Slip::forward (TAO_Notify_ProxySupplier* ps, bool filter) // must be the first action ACE_ASSERT (this->state_ == rssCREATING); - TAO_Notify_Refcountable_Guard_T<TAO_Notify_ProxySupplier> psgrd(ps); + TAO_Notify_ProxySupplier::Ptr psgrd(ps); Routing_Slip_Guard guard (this->internals_); enter_state_transient (guard); @@ -336,7 +336,7 @@ Routing_Slip::dispatch ( // cannot be the first action ACE_ASSERT (this->state_ != rssCREATING); - TAO_Notify_Refcountable_Guard_T<TAO_Notify_ProxySupplier> psgrd(ps); + TAO_Notify_ProxySupplier::Ptr psgrd(ps); Routing_Slip_Guard guard (this->internals_); size_t request_id = delivery_requests_.size (); @@ -363,7 +363,7 @@ Routing_Slip::dispatch ( this->sequence_, static_cast<int> (request_id), ps->id())); - ps->worker_task()->execute (method ACE_ENV_ARG_PARAMETER); + ps->execute_task (method ACE_ENV_ARG_PARAMETER); ACE_CHECK; } else diff --git a/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip.h b/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip.h index 807227b5556..eb9855cd922 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip.h @@ -67,7 +67,7 @@ class TAO_Notify_Serv_Export Routing_Slip : public Persistent_Callback typedef ACE_Guard< TAO_SYNCH_MUTEX > Routing_Slip_Guard; public: /// "Factory" method for normal use. - static Routing_Slip_Ptr create (const TAO_Notify_Event_var& event + static Routing_Slip_Ptr create (const TAO_Notify_Event::Ptr& event ACE_ENV_ARG_DECL); /// "Factory" method for use during reload from persistent storage. @@ -115,7 +115,7 @@ public: ///////////////////////////////////////////////////// // \brief Access the event associated with this routing slip - const TAO_Notify_Event_var & event () const; + const TAO_Notify_Event::Ptr & event () const; /// \brief Provide an identifying number for this Routing Slip /// to use in debug messages. @@ -148,7 +148,7 @@ private: bool create_persistence_manager(); /// Private constructor for use by create method - Routing_Slip(const TAO_Notify_Event_var& event); + Routing_Slip(const TAO_Notify_Event::Ptr& event); /// Test to see if all deliveries are complete. bool all_deliveries_complete () const; @@ -176,7 +176,7 @@ private: Routing_Slip_Ptr this_ptr_; // The event being delivered. - TAO_Notify_Event_var event_; + TAO_Notify_Event::Ptr event_; /// A mini-state machine to control persistence /// See external doc for circles and arrows. diff --git a/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip_Persistence_Manager.cpp b/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip_Persistence_Manager.cpp index 2fbb2ed3430..de75b16dae0 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip_Persistence_Manager.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Routing_Slip_Persistence_Manager.cpp @@ -275,7 +275,6 @@ Routing_Slip_Persistence_Manager::Block_Header::Block_Header(Header_Type type) , data_size(0) { } - Routing_Slip_Persistence_Manager::Block_Header::~Block_Header (void) { } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp deleted file mode 100644 index 87c85962bdc..00000000000 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// $Id$ - -#include "Batch_Buffering_Strategy.h" -#include "../Method_Request_Event.h" -#include "ace/Null_Condition.h" - -ACE_RCSID (Notify, TAO_Notify_Batch_Buffering_Strategy, "$Id$") - -TAO_Notify_Batch_Buffering_Strategy::TAO_Notify_Batch_Buffering_Strategy (TAO_Notify_Message_Queue& msg_queue, TAO_Notify_AdminProperties_var& admin_properties, CORBA::Long batch_size) - :TAO_Notify_Buffering_Strategy (msg_queue, admin_properties, batch_size) -{ -} - -TAO_Notify_Batch_Buffering_Strategy::~TAO_Notify_Batch_Buffering_Strategy () -{ -} - -int -TAO_Notify_Batch_Buffering_Strategy::dequeue_batch (CosNotification::EventBatch& event_batch) -{ - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, -1); - - // if batch_size is infinite, simply dequeue everything available. - - int pending = 0; // not used. - - if (this->batch_size_ == 0) - { - return this->dequeue_available (event_batch, pending); - } - else - { - // block till batch size of events are available. - while (this->msg_queue_.message_count () < this->batch_size_) - { - if (this->shutdown_ == 1) // if we're shutdown, don't play this silly game. - return -1; - - this->batch_size_reached_condition_.wait (); - } - - return this->dequeue_i (this->batch_size_, event_batch); - } -} - -int -TAO_Notify_Batch_Buffering_Strategy::dequeue_available (CosNotification::EventBatch& event_batch, int &pending) -{ - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, -1); - - int deq_count = this->msg_queue_.message_count (); - - if (this->batch_size_ != 0 && deq_count > this->batch_size_) // Restrict upto batch size. - deq_count = this->batch_size_; - - pending = this->msg_queue_.message_count () - deq_count; - - return this->dequeue_i (deq_count, event_batch); -} - -int -TAO_Notify_Batch_Buffering_Strategy::dequeue_i (int max_deq_count, CosNotification::EventBatch& event_batch) -{ - ACE_Message_Block *mb; - - int deq_count = 0; - - event_batch.length (max_deq_count); - - for (; deq_count < max_deq_count; ++deq_count) - { - if (this->msg_queue_.dequeue (mb) == -1) - break; // error, simply return what we could extract so far. - - --this->global_queue_length_; - - TAO_Notify_Method_Request_Event_Queueable* mre = dynamic_cast<TAO_Notify_Method_Request_Event_Queueable*> (mb); - - mre->event ()->convert (event_batch[deq_count]); - - ACE_Message_Block::release (mb); - } - - event_batch.length (deq_count); - - this->global_queue_not_full_condition_.signal (); - this->local_queue_not_full_condition_.signal (); - - return deq_count; -} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h deleted file mode 100644 index 069ad98a710..00000000000 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- C++ -*- */ -/** - * @file Batch_Buffering_Strategy.h - * - * $Id$ - * - * @author Pradeep Gore <pradeep@oomworks.com> - * - * - */ - -#ifndef TAO_Notify_BATCH_BUFFERING_STRATEGY_H -#define TAO_Notify_BATCH_BUFFERING_STRATEGY_H -#include /**/ "ace/pre.h" - -#include "../notify_serv_export.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "../Method_Request.h" -#include "../Buffering_Strategy.h" - -/** - * @class TAO_Notify_Batch_Buffering_Strategy - * - * @brief - * - */ -class TAO_Notify_Serv_Export TAO_Notify_Batch_Buffering_Strategy : public TAO_Notify_Buffering_Strategy -{ -public: - /// Constuctor - TAO_Notify_Batch_Buffering_Strategy (TAO_Notify_Message_Queue& msg_queue, TAO_Notify_AdminProperties_var& admin_properties, CORBA::Long batch_size); - - /// Destructor - ~TAO_Notify_Batch_Buffering_Strategy (); - - /// Dequeue batch. This method will block till <batch_size> is available.. - /// Return -1 on error else the number of items actually dequeued. - int dequeue_batch (CosNotification::EventBatch& event_batch); - - /// Dequeue upto batch. This method will not block. - /// Return -1 on error else the number of items dequeued (<batch_size>). - /// <pending> is set to the number of events remaining in the queue. - int dequeue_available (CosNotification::EventBatch& event_batch, int &pending); - -protected: - - /// Extract upto <max_deq_count> number of items. - int dequeue_i (int max_deq_count, CosNotification::EventBatch& event_batch); -}; - -#include /**/ "ace/post.h" -#endif /* TAO_Notify_BATCH_BUFFERING_STRATEGY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.cpp index 11b50b7fd22..15bd1db1eca 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.cpp @@ -22,8 +22,6 @@ TAO_Notify_SequenceProxyPushConsumer::~TAO_Notify_SequenceProxyPushConsumer () void TAO_Notify_SequenceProxyPushConsumer::release (void) { - if (this->supplier_) - this->supplier_->release (); delete this; //@@ inform factory @@ -67,7 +65,7 @@ TAO_Notify_SequenceProxyPushConsumer::push_structured_events (const CosNotificat )) { // Check if we should proceed at all. - if (this->admin_properties_->reject_new_events () == 1 && this->admin_properties_->queue_full ()) + if (this->admin_properties().reject_new_events () == 1 && this->admin_properties().queue_full ()) ACE_THROW (CORBA::IMP_LIMIT ()); if (this->is_connected () == 0) @@ -91,6 +89,7 @@ TAO_Notify_SequenceProxyPushConsumer::disconnect_sequence_push_consumer (ACE_ENV CORBA::SystemException )) { + TAO_Notify_SequenceProxyPushConsumer::Ptr guard( this ); this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h index c20233c05c8..5e65ea9f03b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h @@ -45,10 +45,7 @@ public: TAO_Notify_SequenceProxyPushConsumer (void); /// Destructor - ~TAO_Notify_SequenceProxyPushConsumer (); - - /// TAO_Notify_Destroy_Callback methods - virtual void release (void); + virtual ~TAO_Notify_SequenceProxyPushConsumer (); virtual const char * get_proxy_type_name (void) const; @@ -86,6 +83,10 @@ protected: ACE_THROW_SPEC (( CORBA::SystemException )); + +private: + /// TAO_Notify_Destroy_Callback methods + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.cpp index 8cf6ba6cc64..c87728df2ab 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.cpp @@ -19,8 +19,6 @@ TAO_Notify_SequenceProxyPushSupplier::~TAO_Notify_SequenceProxyPushSupplier () void TAO_Notify_SequenceProxyPushSupplier::release (void) { - if (this->consumer_) - this->consumer_->release (); delete this; //@@ inform factory @@ -40,7 +38,7 @@ TAO_Notify_SequenceProxyPushSupplier::connect_sequence_push_consumer (CosNotifyC TAO_Notify_SequencePushConsumer (this), CORBA::NO_MEMORY ()); - consumer->init (push_consumer, this->admin_properties_ ACE_ENV_ARG_PARAMETER); + consumer->init (push_consumer ACE_ENV_ARG_PARAMETER); ACE_CHECK; this->connect (consumer ACE_ENV_ARG_PARAMETER); @@ -55,6 +53,7 @@ TAO_Notify_SequenceProxyPushSupplier::disconnect_sequence_push_supplier (ACE_ENV )) { + TAO_Notify_SequenceProxyPushSupplier::Ptr guard( this ); this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.h index 528dbda5d8b..2d727b94e33 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.h @@ -52,10 +52,8 @@ public: TAO_Notify_SequenceProxyPushSupplier (void); /// Destructor - ~TAO_Notify_SequenceProxyPushSupplier (); + virtual ~TAO_Notify_SequenceProxyPushSupplier (); - /// TAO_Notify_Destroy_Callback methods - virtual void release (void); virtual const char * get_proxy_type_name (void) const; @@ -83,6 +81,9 @@ public: ACE_THROW_SPEC (( CORBA::SystemException )); + + /// TAO_Notify_Destroy_Callback methods + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp index 28e43c87dba..689272a738d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp @@ -21,7 +21,7 @@ ACE_RCSID (Notify, TAO_Notify_SequencePushConsumer, "$Id$") #endif //DEBUG_LEVEL TAO_Notify_SequencePushConsumer::TAO_Notify_SequencePushConsumer (TAO_Notify_ProxySupplier* proxy) - : TAO_Notify_Consumer (proxy) +: TAO_Notify_Consumer (proxy) { } @@ -30,31 +30,11 @@ TAO_Notify_SequencePushConsumer::~TAO_Notify_SequencePushConsumer () } void -TAO_Notify_SequencePushConsumer::init ( - CosNotifyComm::SequencePushConsumer_ptr push_consumer, TAO_Notify_AdminProperties_var& admin_properties -#if 1 - ACE_ENV_ARG_DECL_NOT_USED) -#else //1 - ACE_ENV_ARG_DECL) -#endif +TAO_Notify_SequencePushConsumer::init (CosNotifyComm::SequencePushConsumer_ptr push_consumer ACE_ENV_ARG_DECL_NOT_USED) { - set_consumer (push_consumer); + ACE_ASSERT (this->push_consumer_.in() == 0); + ACE_ASSERT (push_consumer != 0); -#if 1 //// @@ TODO: use buffering strategy in TAO_Notify_Consumer??? - ACE_UNUSED_ARG ( admin_properties); -#else //1 - - ACE_NEW_THROW_EX (this->buffering_strategy_, - TAO_Notify_Batch_Buffering_Strategy (this->msg_queue_, admin_properties, - this->max_batch_size_.value ()), - CORBA::NO_MEMORY ()); -#endif // 1 -} - -void -TAO_Notify_SequencePushConsumer::set_consumer ( - CosNotifyComm::SequencePushConsumer_ptr push_consumer) -{ this->push_consumer_ = CosNotifyComm::SequencePushConsumer::_duplicate (push_consumer); this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (push_consumer); @@ -164,11 +144,15 @@ TAO_Notify_SequencePushConsumer::dispatch_from_queue (Request_Queue& requests, A static_cast<int> (this->proxy ()->id ()), request->sequence () )); - ace_mon.acquire (); requests.enqueue_head (request); // put the failed event back where it was result = false; break; } + default: + { + result = false; + break; + } } } return result; @@ -184,13 +168,15 @@ TAO_Notify_SequencePushConsumer::enqueue_if_necessary ( this->enqueue_request (request ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (false); - if (this->pacing_.is_valid ()) + size_t mbs = static_cast<size_t>(this->max_batch_size_.value()); + + if (this->pending_events().size() >= mbs || this->pacing_.is_valid () == 0) { - schedule_timer (false); + this->dispatch_pending (ACE_ENV_SINGLE_ARG_PARAMETER); } else { - this->dispatch_pending (ACE_ENV_SINGLE_ARG_PARAMETER); + schedule_timer (false); } return true; } @@ -239,10 +225,11 @@ TAO_Notify_SequencePushConsumer::get_ior (ACE_CString & iorstr) const void TAO_Notify_SequencePushConsumer::reconnect_from_consumer (TAO_Notify_Consumer* old_consumer - ACE_ENV_ARG_DECL_NOT_USED) + ACE_ENV_ARG_DECL) { TAO_Notify_SequencePushConsumer* tmp = dynamic_cast<TAO_Notify_SequencePushConsumer *> (old_consumer); ACE_ASSERT(tmp != 0); - this->set_consumer(tmp->push_consumer_.in()); + this->init(tmp->push_consumer_.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK; this->schedule_timer(false); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h index 76ff5d049ed..09cfbf71969 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h @@ -25,7 +25,6 @@ #include "../Property_T.h" #include "../Consumer.h" #include "../AdminProperties.h" -#include "Batch_Buffering_Strategy.h" #include "ace/Null_Condition.h" class TAO_Notify_ProxySupplier; @@ -42,19 +41,12 @@ class TAO_Notify_Serv_Export TAO_Notify_SequencePushConsumer : public TAO_Notify_Consumer { public: - /// Constuctor TAO_Notify_SequencePushConsumer (TAO_Notify_ProxySupplier* proxy); - /// Destructor - ~TAO_Notify_SequencePushConsumer (); + virtual ~TAO_Notify_SequencePushConsumer (); /// Init the Consumer - void init (CosNotifyComm::SequencePushConsumer_ptr push_consumer, TAO_Notify_AdminProperties_var& admin_properties ACE_ENV_ARG_DECL); - - void set_consumer (CosNotifyComm::SequencePushConsumer_ptr push_consumer); - - /// TAO_Notify_Destroy_Callback methods. - virtual void release (void); + void init (CosNotifyComm::SequencePushConsumer_ptr push_consumer ACE_ENV_ARG_DECL); /// Add request to a queue if necessary. /// for Sequence it's always necessary. @@ -89,6 +81,9 @@ protected: /// The Consumer CosNotifyComm::SequencePushConsumer_var push_consumer_; +private: + /// TAO_Notify_Destroy_Callback methods. + virtual void release (void); }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.cpp index e394b2a8f37..adaaf0b24af 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.cpp @@ -18,6 +18,8 @@ TAO_Notify_SequencePushSupplier::~TAO_Notify_SequencePushSupplier () void TAO_Notify_SequencePushSupplier::init (CosNotifyComm::SequencePushSupplier_ptr push_supplier ACE_ENV_ARG_DECL_NOT_USED) { + ACE_ASSERT (push_supplier != 0 && this->push_supplier_.in() == 0); + this->push_supplier_ = CosNotifyComm::SequencePushSupplier::_duplicate (push_supplier); this->subscribe_ = CosNotifyComm::NotifySubscribe::_duplicate (push_supplier); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.h index bfebfd33ea2..24d778e400f 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.h @@ -37,7 +37,7 @@ public: TAO_Notify_SequencePushSupplier (TAO_Notify_ProxyConsumer* proxy); /// Destructor - ~TAO_Notify_SequencePushSupplier (); + virtual ~TAO_Notify_SequencePushSupplier (); /// Init void init (CosNotifyComm::SequencePushSupplier_ptr push_supplier ACE_ENV_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Service.h b/TAO/orbsvcs/orbsvcs/Notify/Service.h index 06881c5b999..5707eb4dfb1 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Service.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Service.h @@ -36,11 +36,11 @@ class TAO_Notify_Serv_Export TAO_Notify_Service : public ACE_Service_Object { public: - /// Define Service_Object method otherwise SunCC compiler complains. - virtual int init (int argc, char *argv[]) = 0; + /// Init the service from configurator + virtual int init (int argc, ACE_TCHAR *argv[]) = 0; /// Init the service. - virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) = 0; + virtual void init_service (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) = 0; /// Create the Channel Factory. virtual CosNotifyChannelAdmin::EventChannelFactory_ptr create ( diff --git a/TAO/orbsvcs/orbsvcs/Notify/Standard_Event_Persistence.cpp b/TAO/orbsvcs/orbsvcs/Notify/Standard_Event_Persistence.cpp index ca0f91d23a6..6f2170a3bf9 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Standard_Event_Persistence.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Standard_Event_Persistence.cpp @@ -10,7 +10,7 @@ namespace TAO_Notify { Standard_Event_Persistence::Standard_Event_Persistence () - : filename_ ("__PERSISTENT_EVENT__.DB") + : filename_ (ACE_TEXT ("__PERSISTENT_EVENT__.DB")) , block_size_ (512) , factory_ (0) { @@ -58,14 +58,14 @@ Standard_Event_Persistence::init (int argc, ACE_TCHAR *argv[]) for (int narg = 0; narg < argc; ++narg) { ACE_TCHAR * av = argv[narg]; - if (ACE_OS::strcasecmp (av, "-v") == 0) + if (ACE_OS::strcasecmp (av, ACE_TEXT ("-v")) == 0) { verbose = true; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Standard_Event_Persistence: -verbose\n") )); } - else if (ACE_OS::strcasecmp (av, "-file_path") == 0 && narg + 1 < argc) + else if (ACE_OS::strcasecmp (av, ACE_TEXT ("-file_path")) == 0 && narg + 1 < argc) { this->filename_ = argv[narg + 1]; if (TAO_debug_level > 0 || verbose) @@ -77,7 +77,7 @@ Standard_Event_Persistence::init (int argc, ACE_TCHAR *argv[]) } narg += 1; } - else if (ACE_OS::strcasecmp (av, "-block_size") == 0 && narg + 1 < argc) + else if (ACE_OS::strcasecmp (av, ACE_TEXT ("-block_size")) == 0 && narg + 1 < argc) { this->block_size_ = ACE_OS::atoi(argv[narg + 1]); if (TAO_debug_level > 0 || verbose) @@ -119,7 +119,7 @@ Standard_Event_Persistence_Factory::Standard_Event_Persistence_Factory () } bool -Standard_Event_Persistence_Factory::open (const char * filename, +Standard_Event_Persistence_Factory::open (const ACE_TCHAR* filename, ACE_UINT32 block_size) { bool result = false; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Standard_Event_Persistence.h b/TAO/orbsvcs/orbsvcs/Notify/Standard_Event_Persistence.h index ef142dd451e..240ae9533be 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Standard_Event_Persistence.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Standard_Event_Persistence.h @@ -47,7 +47,7 @@ namespace TAO_Notify /// persistent information. /// /param block_size the size of a physical block on the device containing /// the file. - bool open (const char * filename, ACE_UINT32 block_size = 512); + bool open (const ACE_TCHAR* filename, ACE_UINT32 block_size = 512); ////////////////////////////////////////////////////// // Implement Event_Persistence_Factory virtual methods. @@ -113,11 +113,11 @@ namespace TAO_Notify // get the current factory, creating it if necessary virtual Event_Persistence_Factory * get_factory (); + private: // release the current factory so a new one can be created virtual void reset (); - private: - ACE_CString filename_; // set via -file_path + ACE_TString filename_; // set via -file_path ACE_UINT32 block_size_; // set via -block_size Standard_Event_Persistence_Factory * factory_; }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.cpp index 44027df4771..96fb800047e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.cpp @@ -39,7 +39,7 @@ TAO_Notify_RT_StructuredProxyPushSupplier::activate (PortableServer::Servant , } void -TAO_Notify_RT_StructuredProxyPushSupplier::deliver_request (TAO_Notify_Method_Request_Dispatch & request ACE_ENV_ARG_DECL) +TAO_Notify_RT_StructuredProxyPushSupplier::deliver (TAO_Notify_Method_Request_Dispatch_No_Copy & request ACE_ENV_ARG_DECL) { ACE_TRY { diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.h index 0c5459698a4..9a8c923f626 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RT_StructuredProxyPushSupplier.h @@ -20,7 +20,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "StructuredProxyPushSupplier.h" -class TAO_Notify_Method_Request; /** * @class TAO_Notify_RT_StructuredProxyPushSupplier @@ -46,7 +45,7 @@ public: CORBA::Long id ACE_ENV_ARG_DECL); /// Dispatch Event to consumer - void deliver_request (TAO_Notify_Method_Request_Dispatch & request ACE_ENV_ARG_DECL); + void deliver (TAO_Notify_Method_Request_Dispatch_No_Copy & request ACE_ENV_ARG_DECL); /// Dispatch Event to consumer, no filtering virtual void push_no_filtering (const TAO_Notify_Event* event ACE_ENV_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp index e226e837d4a..07af41b5514 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp @@ -135,10 +135,3 @@ TAO_Notify_StructuredEvent::TAO_Notify_StructuredEvent (const CosNotification::S TAO_Notify_StructuredEvent::~TAO_Notify_StructuredEvent () { } - -const TAO_Notify_Event * -TAO_Notify_StructuredEvent::queueable_copy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)const -{ - return this; -} - diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h index a1623ec454f..516f40d35c4 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h @@ -38,7 +38,7 @@ public: TAO_Notify_StructuredEvent_No_Copy (const CosNotification::StructuredEvent& notification); /// Destructor - ~TAO_Notify_StructuredEvent_No_Copy (); + virtual ~TAO_Notify_StructuredEvent_No_Copy (); /// marshal this event into a CDR buffer (for persistence) virtual void marshal (TAO_OutputCDR & cdr) const; @@ -96,10 +96,8 @@ public: TAO_Notify_StructuredEvent (const CosNotification::StructuredEvent& notification); /// Destructor - ~TAO_Notify_StructuredEvent (); + virtual ~TAO_Notify_StructuredEvent (); - /// returns this - virtual const TAO_Notify_Event * queueable_copy (ACE_ENV_SINGLE_ARG_DECL)const; protected: /// Copy of the Event. diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp index 8aaf6235aac..2a4a1c5ee0d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp @@ -4,7 +4,7 @@ ACE_RCSID(RT_Notify, TAO_Notify_StructuredProxyPushConsumer, "$Id$") -#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Bound_Ptr.h" #include "ace/Auto_Ptr.h" #include "tao/debug.h" #include "StructuredPushSupplier.h" @@ -23,9 +23,6 @@ TAO_Notify_StructuredProxyPushConsumer::~TAO_Notify_StructuredProxyPushConsumer void TAO_Notify_StructuredProxyPushConsumer::release (void) { - if (this->supplier_) - this->supplier_->release (); - delete this; //@@ inform factory } @@ -67,8 +64,8 @@ TAO_Notify_StructuredProxyPushConsumer::push_structured_event (const CosNotifica )) { // Check if we should proceed at all. - if (this->admin_properties_->reject_new_events () == 1 - && this->admin_properties_->queue_full ()) + if (this->admin_properties().reject_new_events () == 1 + && this->admin_properties().queue_full ()) ACE_THROW (CORBA::IMP_LIMIT ()); if (this->is_connected () == 0) @@ -86,6 +83,7 @@ TAO_Notify_StructuredProxyPushConsumer::disconnect_structured_push_consumer (ACE CORBA::SystemException )) { + TAO_Notify_StructuredProxyPushConsumer::Ptr guard( this ); this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h index 5c56d984970..d6dd54df0ce 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h @@ -46,10 +46,8 @@ public: TAO_Notify_StructuredProxyPushConsumer (void); /// Destructor - ~TAO_Notify_StructuredProxyPushConsumer (); + virtual ~TAO_Notify_StructuredProxyPushConsumer (); - /// Release - virtual void release (void); virtual void load_attrs (const TAO_Notify::NVPList& attrs); @@ -87,6 +85,11 @@ protected: )); virtual const char * get_proxy_type_name (void) const; + +private: + + /// Release + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp index 6cbe8d178b2..b2febd45d52 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp @@ -22,8 +22,6 @@ TAO_Notify_StructuredProxyPushSupplier::~TAO_Notify_StructuredProxyPushSupplier void TAO_Notify_StructuredProxyPushSupplier::release (void) { - if (this->consumer_) - this->consumer_->release (); delete this; //@@ inform factory @@ -67,6 +65,7 @@ TAO_Notify_StructuredProxyPushSupplier::disconnect_structured_push_supplier (ACE )) { + TAO_Notify_StructuredProxyPushSupplier::Ptr guard( this ); this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h index 6fbcc8653a9..6e7cef6146f 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h @@ -53,10 +53,8 @@ public: TAO_Notify_StructuredProxyPushSupplier (void); /// Destructor - ~TAO_Notify_StructuredProxyPushSupplier (); + virtual ~TAO_Notify_StructuredProxyPushSupplier (); - /// Release - virtual void release (void); virtual void load_attrs (const TAO_Notify::NVPList& attrs); @@ -86,6 +84,10 @@ public: virtual const char * get_proxy_type_name (void) const; +private: + + /// Release + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp index df093040c74..69c05d5be02 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp @@ -5,7 +5,7 @@ ACE_RCSID(RT_Notify, TAO_Notify_StructuredPushConsumer, "$Id$") #include "../Properties.h" #include "../Event.h" -#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Bound_Ptr.h" TAO_Notify_StructuredPushConsumer::TAO_Notify_StructuredPushConsumer (TAO_Notify_ProxySupplier* proxy) :TAO_Notify_Consumer (proxy) @@ -19,6 +19,8 @@ TAO_Notify_StructuredPushConsumer::~TAO_Notify_StructuredPushConsumer () void TAO_Notify_StructuredPushConsumer::init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL_NOT_USED) { + ACE_ASSERT (push_consumer != 0 && this->push_consumer_.in() == 0); + this->push_consumer_ = CosNotifyComm::StructuredPushConsumer::_duplicate (push_consumer); this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (push_consumer); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h index 64cf2fbd424..b467d85c403 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h @@ -40,10 +40,7 @@ public: void init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL); /// Destructor - ~TAO_Notify_StructuredPushConsumer (); - - /// Release - virtual void release (void); + virtual ~TAO_Notify_StructuredPushConsumer (); /// Push <event> to this consumer. // virtual void push_i (const TAO_Notify_Event* event ACE_ENV_ARG_DECL); @@ -70,6 +67,10 @@ public: protected: /// The Consumer CosNotifyComm::StructuredPushConsumer_var push_consumer_; + +private: + /// Release + virtual void release (void); }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp index e93ce72b0bb..e646558475c 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp @@ -17,6 +17,8 @@ TAO_Notify_StructuredPushSupplier::~TAO_Notify_StructuredPushSupplier () void TAO_Notify_StructuredPushSupplier::init (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL_NOT_USED) { + ACE_ASSERT (push_supplier != 0 && this->push_supplier_.in() == 0); + this->push_supplier_ = CosNotifyComm::StructuredPushSupplier::_duplicate (push_supplier); this->subscribe_ = CosNotifyComm::NotifySubscribe::_duplicate (push_supplier); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h index 9468e99cbeb..ccbe0255735 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h @@ -37,13 +37,11 @@ public: TAO_Notify_StructuredPushSupplier (TAO_Notify_ProxyConsumer* proxy); /// Destructor - ~TAO_Notify_StructuredPushSupplier (); + virtual ~TAO_Notify_StructuredPushSupplier (); /// Init void init (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL); - /// Release - virtual void release (void); /// Retrieve the ior of this peer virtual bool get_ior (ACE_CString & iorstr) const; @@ -51,6 +49,10 @@ public: protected: /// The Supplier CosNotifyComm::StructuredPushSupplier_var push_supplier_; + +private: + /// Release + virtual void release (void); }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h index 4c8813d5055..e80974cf60e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h @@ -37,7 +37,7 @@ public: TAO_Notify_Subscription_Change_Worker (const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed); /// Destructor - ~TAO_Notify_Subscription_Change_Worker (); + virtual ~TAO_Notify_Subscription_Change_Worker (); ///= TAO_ESF_Worker method void work (TAO_Notify_Proxy* proxy ACE_ENV_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.h b/TAO/orbsvcs/orbsvcs/Notify/Supplier.h index 5a2d12d05f0..f962cb09302 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Supplier.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.h @@ -37,7 +37,7 @@ public: TAO_Notify_Supplier (TAO_Notify_ProxyConsumer* proxy); /// Destructor - ~TAO_Notify_Supplier (); + virtual ~TAO_Notify_Supplier (); /// Access Specific Proxy. TAO_Notify_ProxyConsumer* proxy_consumer (void); diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp index c0437f84ead..cc661b4b2a2 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp @@ -266,7 +266,7 @@ TAO_Notify_SupplierAdmin::push_consumers (ACE_ENV_SINGLE_ARG_DECL) { TAO_Notify_Proxy_Seq_Worker seq_worker; - return seq_worker.create (*this->proxy_container_ ACE_ENV_ARG_PARAMETER); + return seq_worker.create (this->proxy_container() ACE_ENV_ARG_PARAMETER); } CosNotifyChannelAdmin::ProxyConsumer_ptr @@ -278,7 +278,7 @@ TAO_Notify_SupplierAdmin::get_proxy_consumer (CosNotifyChannelAdmin::ProxyID pro { TAO_Notify_ProxyConsumer_Find_Worker find_worker; - return find_worker.resolve (proxy_id, *this->proxy_container_ ACE_ENV_ARG_PARAMETER); + return find_worker.resolve (proxy_id, this->proxy_container() ACE_ENV_ARG_PARAMETER); } void @@ -304,7 +304,7 @@ TAO_Notify_SupplierAdmin::offer_change (const CosNotification::EventTypeSeq & ad TAO_Notify_Subscription_Change_Worker worker (added, removed); - this->proxy_container_->collection ()->for_each (&worker ACE_ENV_ARG_PARAMETER); + this->proxy_container().collection ()->for_each (&worker ACE_ENV_ARG_PARAMETER); } } @@ -416,7 +416,7 @@ TAO_Notify_SupplierAdmin::find_proxy_consumer ( if (position < path_size) { TAO_Notify_ProxyConsumer_Find_Worker find_worker; - TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], *this->proxy_container_ ACE_ENV_ARG_PARAMETER); + TAO_Notify_Proxy * proxy = find_worker.find (id_path[position], this->proxy_container() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); result = dynamic_cast <TAO_Notify_ProxyConsumer *> (proxy); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h index e5ad8085f09..831ad3c7e6e 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h @@ -42,11 +42,13 @@ class TAO_Notify_Serv_Export TAO_Notify_SupplierAdmin public virtual TAO_Notify_Admin { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_SupplierAdmin > Ptr; + /// Constuctor TAO_Notify_SupplierAdmin (void); /// Destructor - ~TAO_Notify_SupplierAdmin (); + virtual ~TAO_Notify_SupplierAdmin (); /// Init void init (TAO_Notify_EventChannel *ec ACE_ENV_ARG_DECL); @@ -55,8 +57,6 @@ public: virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); - /// Release - virtual void release (void); virtual const char * get_admin_type_name () const; @@ -202,6 +202,10 @@ protected: ACE_ENV_SINGLE_ARG_DECL ) ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + /// Release + virtual void release (void); }; #if defined(_MSC_VER) diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp index 1bbd9c1f7cf..ad1f7c38fd7 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp @@ -8,24 +8,27 @@ ACE_RCSID(Notify, TAO_Notify_ThreadPool_Task, "$Id$") -#include "tao/debug.h" -#include "tao/ORB_Core.h" #include "Properties.h" #include "Timer_Queue.h" +#include "Buffering_Strategy.h" + +#include "tao/debug.h" +#include "tao/ORB_Core.h" + #include "ace/OS_NS_errno.h" TAO_Notify_ThreadPool_Task::TAO_Notify_ThreadPool_Task (void) - : buffering_strategy_ (0), shutdown_ (0), timer_ (0) + : shutdown_ (false) + , shutdown_handler_(this) { } TAO_Notify_ThreadPool_Task::~TAO_Notify_ThreadPool_Task () { - delete this->buffering_strategy_; } int -TAO_Notify_ThreadPool_Task::init (int argc, char **argv) +TAO_Notify_ThreadPool_Task::init (int argc, ACE_TCHAR **argv) { return this->ACE_Task<ACE_NULL_SYNCH>::init (argc, argv); } @@ -33,22 +36,27 @@ TAO_Notify_ThreadPool_Task::init (int argc, char **argv) TAO_Notify_Timer* TAO_Notify_ThreadPool_Task::timer (void) { - this->timer_->_incr_refcnt (); - - return this->timer_; + return this->timer_.get(); } void -TAO_Notify_ThreadPool_Task::init (const NotifyExt::ThreadPoolParams& tp_params, TAO_Notify_AdminProperties_var& admin_properties ACE_ENV_ARG_DECL) +TAO_Notify_ThreadPool_Task::init (const NotifyExt::ThreadPoolParams& tp_params, TAO_Notify_AdminProperties::Ptr& admin_properties ACE_ENV_ARG_DECL) { - ACE_NEW_THROW_EX (this->timer_, + ACE_ASSERT (this->timer_.get() == 0); + + TAO_Notify_Timer_Queue* timer = 0; + ACE_NEW_THROW_EX (timer, TAO_Notify_Timer_Queue (), CORBA::NO_MEMORY ()); ACE_CHECK; + this->timer_.reset (timer); + - ACE_NEW_THROW_EX (this->buffering_strategy_, - TAO_Notify_Buffering_Strategy (*msg_queue (), admin_properties, 1), + TAO_Notify_Buffering_Strategy* buffering_strategy = 0; + ACE_NEW_THROW_EX (buffering_strategy, + TAO_Notify_Buffering_Strategy (*msg_queue (), admin_properties), CORBA::NO_MEMORY ()); + this->buffering_strategy_.reset (buffering_strategy); ACE_CHECK; long flags = THR_NEW_LWP | THR_JOINABLE; @@ -59,11 +67,12 @@ TAO_Notify_ThreadPool_Task::init (const NotifyExt::ThreadPoolParams& tp_params, flags |= orb->orb_core ()->orb_params ()->thread_creation_flags (); - // Increment the count on this object by the number of threads using it. + // Guards the thread for auto-deletion; paired with close. + // This is done in the originating thread before the spawn to + // avoid any race conditions. + for ( CORBA::ULong i = 0; i < tp_params.static_threads; ++i ) { - ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->TAO_Notify_Refcountable::lock_); - - this->refcount_+=tp_params.static_threads; + this->_incr_refcnt(); } // Become an active object. @@ -72,12 +81,10 @@ TAO_Notify_ThreadPool_Task::init (const NotifyExt::ThreadPoolParams& tp_params, 0, ACE_THR_PRI_OTHER_DEF) == -1) { - // Decrement the count on this object. We know that this object's owner is holding a count on this object so - // we can neglect our responsibility of checking if the refcount is decremented to 0. + // Undo the ref counts on error + for ( CORBA::ULong i = 0; i < tp_params.static_threads; ++i ) { - ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->TAO_Notify_Refcountable::lock_); - - this->refcount_-=tp_params.static_threads; + this->_decr_refcnt(); } if (TAO_debug_level > 0) @@ -98,6 +105,8 @@ TAO_Notify_ThreadPool_Task::init (const NotifyExt::ThreadPoolParams& tp_params, void TAO_Notify_ThreadPool_Task::execute (TAO_Notify_Method_Request& method_request ACE_ENV_ARG_DECL) { + if (!shutdown_) + { TAO_Notify_Method_Request_Queueable& request_copy = *method_request.copy (ACE_ENV_SINGLE_ARG_PARAMETER); if (this->buffering_strategy_->enqueue (request_copy) == -1) @@ -106,6 +115,7 @@ TAO_Notify_ThreadPool_Task::execute (TAO_Notify_Method_Request& method_request A ACE_DEBUG ((LM_DEBUG, "NS_ThreadPool_Task (%P|%t) - " "failed to enqueue\n")); } + } } int @@ -160,25 +170,45 @@ TAO_Notify_ThreadPool_Task::svc (void) void TAO_Notify_ThreadPool_Task::shutdown (void) { - this->shutdown_ = 1; + if (this->shutdown_) + { + return; + } + + this->shutdown_ = true; this->buffering_strategy_->shutdown (); - return; + // be sure this object is not deleted until wait() returns + this->_incr_refcnt (); + + // get another thread to wait() for the thread(s) running svc() to exit + // otherwise the thread is a zombie on Solaris and just hangs around + // on windows. + TAO_Notify_PROPERTIES::instance() + ->orb ()->orb_core ()->reactor ()->notify (&shutdown_handler_); } void TAO_Notify_ThreadPool_Task::release (void) { - this->timer_->_decr_refcnt (); - delete this; } int TAO_Notify_ThreadPool_Task::close (u_long /*flags*/) { - this->_decr_refcnt (); - + // Undo the thread spawn guard. close is called per thread spawned. + this->_decr_refcnt(); return 0; } + +void +TAO_Notify_ThreadPool_Task::wait_for_shutdown () +{ + // wait for thread(s) running svc() to return. + this->wait (); + + // Undo the shutdown request guard. + this->_decr_refcnt (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h index 83ef404dcaa..7e588a4b163 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h @@ -23,12 +23,12 @@ #include "ace/Task.h" #include "ace/Message_Queue.h" #include "ace/Reactor.h" +#include "Timer_Queue.h" #include "AdminProperties.h" #include "Worker_Task.h" class TAO_Notify_Buffering_Strategy; -class TAO_Notify_Timer_Queue; /** * @class TAO_Notify_ThreadPool_Task @@ -45,24 +45,22 @@ public: TAO_Notify_ThreadPool_Task (void); /// Destructor - ~TAO_Notify_ThreadPool_Task (); + virtual ~TAO_Notify_ThreadPool_Task (); /// Call the base class init - virtual int init (int argc, char **argv); + virtual int init (int argc, ACE_TCHAR **argv); + /// release reference to my self. virtual int close (u_long flags); - /// Release - virtual void release (void); - /// Activate the threadpool - void init (const NotifyExt::ThreadPoolParams& tp_params, TAO_Notify_AdminProperties_var& admin_properties ACE_ENV_ARG_DECL); + void init (const NotifyExt::ThreadPoolParams& tp_params, TAO_Notify_AdminProperties::Ptr& admin_properties ACE_ENV_ARG_DECL); /// Queue the request virtual void execute (TAO_Notify_Method_Request& method_request ACE_ENV_ARG_DECL); /// Shutdown task - virtual void shutdown (void); + virtual void shutdown (); /// Update QoS Properties. virtual void update_qos_properties (const TAO_Notify_QoSProperties& qos_properties); @@ -70,22 +68,49 @@ public: /// The object used by clients to register timers. virtual TAO_Notify_Timer* timer (void); - /// Access the Buffering Strategy. - TAO_Notify_Buffering_Strategy* buffering_strategy (void); - protected: /// Task svc virtual int svc (void); private: + /// Release + virtual void release (void); + + /// wait for all threads to exit svc() + virtual void wait_for_shutdown (); + /// The buffering strategy to use. - TAO_Notify_Buffering_Strategy* buffering_strategy_; + ACE_Auto_Ptr< TAO_Notify_Buffering_Strategy > buffering_strategy_; /// Shutdown - int shutdown_; + bool shutdown_; /// The Queue based timer. - TAO_Notify_Timer_Queue* timer_; + TAO_Notify_Timer_Queue::Ptr timer_; + + // Since this class already inherited from ACE_Event_Handler + // I did not want to conflict with a possible parent + /// implementation of handle_exception. + class Shutdown_Handler : public ACE_Event_Handler + { + public: + Shutdown_Handler (TAO_Notify_ThreadPool_Task* owner) : owner_ (owner) {}; + + /// wait for all threads to complete in another thread + virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE) + { + ACE_UNUSED_ARG (fd); + owner_->wait_for_shutdown (); + return 0; + } + private: + TAO_Notify_ThreadPool_Task* owner_; + }; + + friend class Shutdown_Handler; + + Shutdown_Handler shutdown_handler_; + }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl index 275b8c9aaca..4c3d519bd0b 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl @@ -8,8 +8,3 @@ TAO_Notify_ThreadPool_Task::update_qos_properties (const TAO_Notify_QoSPropertie this->buffering_strategy_->update_qos_properties (qos_properties); } -ACE_INLINE TAO_Notify_Buffering_Strategy* -TAO_Notify_ThreadPool_Task::buffering_strategy (void) -{ - return this->buffering_strategy_; -} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer.h b/TAO/orbsvcs/orbsvcs/Notify/Timer.h index 502bc9724ec..89e64785d04 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Timer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer.h @@ -33,6 +33,7 @@ class ACE_Event_Handler; class TAO_Notify_Serv_Export TAO_Notify_Timer : public TAO_Notify_Refcountable { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_Timer > Ptr; /// Destructor virtual ~TAO_Notify_Timer (){}; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h b/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h index b5fd2fd3842..63f82d99983 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer_Queue.h @@ -34,14 +34,14 @@ class TAO_Notify_Serv_Export TAO_Notify_Timer_Queue : public TAO_Notify_Timer { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_Timer_Queue > Ptr; + /// Constuctor TAO_Notify_Timer_Queue (void); /// Destructor virtual ~TAO_Notify_Timer_Queue (); - /// Release - virtual void release (void); /// Schedule a timer virtual long schedule_timer (ACE_Event_Handler *handler, @@ -57,6 +57,10 @@ public: protected: /// The Timer Queue ACE_Timer_Heap timer_queue_; + +private: + /// Release + virtual void release (void); }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h b/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h index cadb1b14071..ea7beb12400 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Timer_Reactor.h @@ -32,14 +32,14 @@ class ACE_Reactor; class TAO_Notify_Serv_Export TAO_Notify_Timer_Reactor : public TAO_Notify_Timer { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_Timer_Reactor > Ptr; + /// Constuctor TAO_Notify_Timer_Reactor (void); /// Destructor virtual ~TAO_Notify_Timer_Reactor (); - /// Release - virtual void release (void); /// Schedule a timer virtual long schedule_timer (ACE_Event_Handler *handler, @@ -52,6 +52,10 @@ public: protected: /// The instance reactor that we use. ACE_Reactor* reactor_; + +private: + /// Release + virtual void release (void); }; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Topology_Object.cpp b/TAO/orbsvcs/orbsvcs/Notify/Topology_Object.cpp index ec790340199..1844d49f8c9 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Topology_Object.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Topology_Object.cpp @@ -38,8 +38,9 @@ namespace TAO_Notify } void - Topology_Object::initialize (Topology_Parent * topology_parent ACE_ENV_ARG_DECL_NOT_USED) + Topology_Object::initialize (Topology_Parent* topology_parent ACE_ENV_ARG_DECL_NOT_USED) { + ACE_ASSERT (topology_parent != 0 && this->topology_parent_ == 0); this->topology_parent_ = topology_parent; TAO_Notify_Object::initialize (topology_parent); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Topology_Object.h b/TAO/orbsvcs/orbsvcs/Notify/Topology_Object.h index abcd8f917c1..e92e78b8da0 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Topology_Object.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Topology_Object.h @@ -30,7 +30,7 @@ /// \namespace TAO_Notify /// \brief A namespace to be used by all of TAO's Notification Service -/// implementation. +/// implementation. /// /// The initial implementation used the TAO_Notify_ prefix rather than /// a namespace. As part of the reliable Notification Service project @@ -44,8 +44,8 @@ // { // namespace Notify {} // -// } -// +// } +// namespace TAO_Notify { static const char TOPOLOGY_ID_NAME[] = "TopologyID"; @@ -109,9 +109,9 @@ namespace TAO_Notify /// Topology objects must be derived from this class to allow themselves /// to be persisted. /// Note: virtual inheritance from TopologySavable is unnecessary, - /// but HP ACC compiler warns if it's not there. - class TAO_Notify_Serv_Export Topology_Object : - public virtual TAO_Notify_Object, + /// but HP ACC compiler warns if it's not there. + class TAO_Notify_Serv_Export Topology_Object : + public virtual TAO_Notify_Object, public virtual Topology_Savable { public: @@ -122,7 +122,7 @@ namespace TAO_Notify virtual ~Topology_Object (); /// Init this object with data from <rhs>. - virtual void initialize (Topology_Parent * topology_parent ACE_ENV_ARG_DECL); + virtual void initialize (Topology_Parent* topology_parent ACE_ENV_ARG_DECL); /// \brief Create a child of the appropriate type and return it. /// diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h index 63169cbf1ea..bef6be6a23f 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h @@ -40,6 +40,8 @@ class TAO_Notify_Buffering_Strategy; class TAO_Notify_Serv_Export TAO_Notify_Worker_Task : public TAO_Notify_Refcountable { public: + typedef TAO_Notify_Refcountable_Guard_T< TAO_Notify_Worker_Task > Ptr; + /// Constuctor TAO_Notify_Worker_Task (void); @@ -56,7 +58,6 @@ public: /// The object used by clients to register timers. virtual TAO_Notify_Timer* timer (void) = 0; - virtual TAO_Notify_Buffering_Strategy* buffering_strategy (void) = 0; protected: /// Destructor diff --git a/TAO/orbsvcs/tests/Notify/Basic/AdminProperties.cpp b/TAO/orbsvcs/tests/Notify/Basic/AdminProperties.cpp index 38f8e9002de..0e2e370f177 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/AdminProperties.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/AdminProperties.cpp @@ -9,7 +9,8 @@ /***************************************************************************/ AdminProperties_Task::AdminProperties_Task (void) - :supplier_ (0), client_ (0) + : supplier_ (0) + , client_ (0) { } @@ -23,8 +24,7 @@ AdminProperties_Task::init (TAO_Notify_Tests_StructuredPushSupplier *supplier, A int AdminProperties_Task::init (int argc, ACE_TCHAR *argv[]) { - return ACE_Task_Base::init (argc, - argv); + return ACE_Task_Base::init (argc, argv); } int @@ -65,7 +65,7 @@ AdminProperties_Task::svc (void) int event_count = this->client_->event_count_; - ACE_DEBUG ((LM_DEBUG, "Supplier sending %d events...\n", event_count)); + ACE_DEBUG ((LM_DEBUG, "\n1 supplier sending %d events...\n", event_count)); ACE_DECLARE_NEW_CORBA_ENV; @@ -73,24 +73,25 @@ AdminProperties_Task::svc (void) { event.filterable_data[0].value <<= (CORBA::Long)i; - // Any. event.remainder_of_body <<= (CORBA::Long)i; ACE_TRY { + ACE_DEBUG((LM_DEBUG, "+")); this->supplier_->send_event (event ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } ACE_CATCH (CORBA::IMP_LIMIT, impl_limit) { - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Event %d was not send due to Impl Limit reached\n", i)); + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "\nEvent %d was not send due to Impl Limit reached\n", i)); - this->client_->was_rejected_ = 1; + ++ this->client_->rejections_; } ACE_CATCHANY { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception sending event\n"); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Error: Exception sending event\n"); + return 1; } ACE_ENDTRY; } @@ -100,25 +101,26 @@ return 0; /***************************************************************************/ AdminProperties_StructuredPushConsumer::AdminProperties_StructuredPushConsumer (AdminProperties* client) - :client_ (client), events_received_ (0) + : client_ (client) + , events_received_ (0) { + client_->consumer_start(this); } void AdminProperties_StructuredPushConsumer::push_structured_event (const CosNotification::StructuredEvent & /*notification*/ - ACE_ENV_ARG_DECL_NOT_USED - ) - ACE_THROW_SPEC (( - CORBA::SystemException, - CosEventComm::Disconnected - )) + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException,CosEventComm::Disconnected)) { ++events_received_; - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Consumer %x received event %d\n", this, events_received_.value ())); + if (events_received_ >= client_->max_queue_length_) + client_->consumer_done(this); + + ACE_DEBUG((LM_DEBUG, "-")); - ACE_OS::sleep (this->client_->consumer_delay_); + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, "\nConsumer %x received event %d\n", this, events_received_.value ())); } /***************************************************************************/ @@ -128,14 +130,12 @@ AdminProperties::AdminProperties (void) max_consumers_ (3), max_suppliers_ (3), reject_new_events_ (0), - consumer_delay_ (0, 0), - initial_delay_ (5, 0), consumers_ (4), suppliers_ (4), event_count_ (30), suppliers_connected_count_ (0), consumers_connected_count_ (0), - was_rejected_ (0) + rejections_ (0) { } @@ -188,18 +188,6 @@ AdminProperties::parse_args(int argc, char *argv[]) // Number of suppliers to create. arg_shifter.consume_arg (); } - else if ((current_arg = arg_shifter.get_the_parameter ("-ConsumerDelay"))) - { - this->consumer_delay_ = ACE_Time_Value (ACE_OS::atoi (current_arg), 0); // Consumer delay in secs. - - arg_shifter.consume_arg (); - } - else if ((current_arg = arg_shifter.get_the_parameter ("-InitialDelay"))) - { - this->initial_delay_ = ACE_Time_Value (ACE_OS::atoi (current_arg), 0); // Initial delay in secs. - - arg_shifter.consume_arg (); - } else if (arg_shifter.cur_arg_strncasecmp ("-?") == 0) { ACE_DEBUG((LM_DEBUG, @@ -210,9 +198,7 @@ AdminProperties::parse_args(int argc, char *argv[]) "-reject_new_events [reject_new_events] " "-consumers [consumers] " "-suppliers [suppliers] " - "-event_count [event_count] " - "-ConsumerDelay [delay_in_sec] " - "-InitialDelay [delay_in_secs]\n", + "-event_count [event_count] ", argv[0], argv[0])); @@ -228,20 +214,11 @@ AdminProperties::parse_args(int argc, char *argv[]) return 0; } -int -AdminProperties::init (int argc, - char *argv [] - ACE_ENV_ARG_DECL) +void +AdminProperties::create_channel(bool reject ACE_ENV_ARG_DECL) { - // Initialize base class. - Notify_Test_Client::init (argc, - argv - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - CosNotifyChannelAdmin::ChannelID id; - // Initialize the admin object. initial_admin_.length (4); this->initial_admin_[0].name = @@ -260,9 +237,7 @@ AdminProperties::init (int argc, this->initial_admin_[3].name = CORBA::string_dup (CosNotification::RejectNewEvents); - this->initial_admin_[3].value <<= CORBA::Any::from_boolean ( - this->reject_new_events_ - ); + this->initial_admin_[3].value <<= CORBA::Any::from_boolean (reject); this->ec_ = notify_factory_->create_channel (this->initial_qos_, this->initial_admin_, @@ -288,51 +263,49 @@ AdminProperties::init (int argc, ACE_CHECK_RETURN (-1); ACE_ASSERT (!CORBA::is_nil (consumer_admin_.in ())); - - return 0; } void AdminProperties::run_test (ACE_ENV_SINGLE_ARG_DECL) { - this->test_max_queue_length (ACE_ENV_SINGLE_ARG_PARAMETER); + bool reject = true; + this->create_channel(reject ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->test_max_queue_length (reject ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->ec_->destroy(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + reject = false; + this->create_channel(reject ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->test_max_queue_length (reject ACE_ENV_ARG_PARAMETER); ACE_CHECK; this->test_max_clients (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - // Destroy the EC and hence release server resources. this->ec_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); } void -AdminProperties::test_max_queue_length (ACE_ENV_SINGLE_ARG_DECL) +AdminProperties::test_max_queue_length (bool reject ACE_ENV_ARG_DECL) { // Create the consumer AdminProperties_StructuredPushConsumer *consumer; - - ACE_NEW (consumer, - AdminProperties_StructuredPushConsumer (this)); - - consumer->init (root_poa_.in () - ACE_ENV_ARG_PARAMETER); + ACE_NEW (consumer, AdminProperties_StructuredPushConsumer (this)); + consumer->init (root_poa_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; - - consumer->connect (this->consumer_admin_.in () - ACE_ENV_ARG_PARAMETER); + consumer->connect (this->consumer_admin_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Create the supplier TAO_Notify_Tests_StructuredPushSupplier *supplier = 0; - ACE_NEW (supplier, - TAO_Notify_Tests_StructuredPushSupplier ()); - - supplier->init (root_poa_.in () - ACE_ENV_ARG_PARAMETER); + ACE_NEW (supplier, TAO_Notify_Tests_StructuredPushSupplier ()); + supplier->init (root_poa_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; - - supplier->connect (this->supplier_admin_.in () - ACE_ENV_ARG_PARAMETER); + supplier->connect (this->supplier_admin_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; AdminProperties_Task supplier_task; @@ -340,50 +313,56 @@ AdminProperties::test_max_queue_length (ACE_ENV_SINGLE_ARG_DECL) // Init the Task to send events; supplier_task.init (supplier, this); - if (supplier_task.activate (THR_NEW_LWP | THR_JOINABLE, - 1) != 0) + if (supplier_task.activate (THR_NEW_LWP | THR_JOINABLE, 1) != 0) { - ACE_ERROR ((LM_ERROR, - "Cannot activate supplier task\n")); + ACE_ERROR ((LM_ERROR, "\nCannot activate supplier task\n")); } - ACE_OS::sleep (initial_delay_); // Consumers receive events in the main thread. delay receiving the 1st event. - - CORBA::Long previous_count = 0; - - do{ - previous_count = consumer->events_received_.value (); - - // we add a full 1 sec. to the waiting period for a new event. - ACE_Time_Value waiting_period (this->consumer_delay_.sec () + 1, 0); - - this->orb_->run (waiting_period); - - }while (previous_count != consumer->events_received_.value ()); - - // Test ended. - // wait for the supplier task to finish. + // All supplier events should be sent before the first consumer event is + // received. This relies on our use of -ORBClientConnectionHandler RW. supplier_task.wait (); + this->ORB_run(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // consumer is destroyed by consumer->disconnect() CORBA::Long received_count = consumer->events_received_.value (); // disconnect the participants. consumer->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; supplier->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; - // check the results and print the assessment. - // we expect to see event_count_+1 events + // If the reject_new_events setting == true, then the supplier should + // have received an imp_limit exception for each event it tried to push + // after the maximum was reached. + // If the reject_new_events setting == false, then the events should + // have been discarded according to the DiscardPolicy, which for this + // test we leave as AnyOrder. - ACE_DEBUG ((LM_DEBUG, "Supplier send %d events, consumer received %d events, max_queue_length = %d\n", + ACE_DEBUG ((LM_DEBUG, "\nSupplier sent %d events, consumer received %d events, max_queue_length = %d\n", event_count_, received_count, max_queue_length_)); - if (received_count > this->max_queue_length_ + 1) - { - ACE_DEBUG ((LM_ERROR, "Error: MaxQueueLength exceeded, try increasing consumer delay (currently = %d)\n", - this->consumer_delay_.sec ())); + int expected_min = max_queue_length_; + int expected_max = max_queue_length_ + max_consumers_; + if (reject) + { + expected_max = event_count_ - rejections_; + expected_min = expected_max; + } - if (this->reject_new_events_ == 1 && was_rejected_ == 0) - ACE_DEBUG ((LM_ERROR, "RejectNewEvents failed\n")); + if (reject && rejections_ != event_count_ - received_count) + { + ACE_ERROR ((LM_ERROR, "\nError: Expected %d rejections, but got %d\n", + event_count_ - received_count, rejections_)); + return; + } + + if (received_count < expected_min || received_count > expected_max) + { + ACE_ERROR ((LM_ERROR, "\nError: Expected %d to %d events, but received %d\n", + expected_min, expected_max, received_count)); } } @@ -398,11 +377,11 @@ AdminProperties::test_max_clients (ACE_ENV_SINGLE_ARG_DECL) // check the results and print the assessment. if (this->consumers_connected_count_ > this->max_consumers_) - ACE_DEBUG ((LM_ERROR, "Connected consumers %d, exceed MaxConsumers %d\n", + ACE_DEBUG ((LM_ERROR, "\nConnected consumers %d, exceed MaxConsumers %d\n", this->consumers_connected_count_ > this->max_consumers_)); if (this->suppliers_connected_count_ > this->max_suppliers_) - ACE_DEBUG ((LM_ERROR, "Connected suppliers %d, exceed MaxSuppliers %d\n", + ACE_DEBUG ((LM_ERROR, "\nConnected suppliers %d, exceed MaxSuppliers %d\n", this->suppliers_connected_count_ > this->max_suppliers_)); } @@ -424,8 +403,7 @@ AdminProperties::create_suppliers (ACE_ENV_SINGLE_ARG_DECL) { ACE_NEW (supplier, TAO_Notify_Tests_StructuredPushSupplier ()); - supplier->init (root_poa_.in () - ACE_ENV_ARG_PARAMETER); + supplier->init (root_poa_.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; supplier->connect (this->supplier_admin_.in () @@ -438,12 +416,12 @@ AdminProperties::create_suppliers (ACE_ENV_SINGLE_ARG_DECL) ACE_CATCH (CORBA::IMP_LIMIT, impl_limit) { if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Impl Limit excpetion when connecting supplier\n")); + ACE_DEBUG ((LM_DEBUG, "\nImpl Limit excpetion when connecting supplier\n")); } ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Exception in connecting supplier\n"); + "\nError: Exception in connecting supplier\n"); } ACE_ENDTRY; } @@ -464,14 +442,11 @@ AdminProperties::create_consumers (ACE_ENV_SINGLE_ARG_DECL) for (index = 0; index < this->consumers_; ++index) { - ACE_NEW (consumer, - TAO_Notify_Tests_StructuredPushConsumer ()); - consumer->init (root_poa_.in () - ACE_ENV_ARG_PARAMETER); + ACE_NEW (consumer, TAO_Notify_Tests_StructuredPushConsumer ()); + consumer->init (root_poa_.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - consumer->connect (this->consumer_admin_.in () - ACE_ENV_ARG_PARAMETER); + consumer->connect (this->consumer_admin_.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; this->consumers_connected_count_++; @@ -480,13 +455,12 @@ AdminProperties::create_consumers (ACE_ENV_SINGLE_ARG_DECL) ACE_CATCH (CORBA::IMP_LIMIT, impl_limit) { if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Impl Limit excpetion when connecting consumer\n")); + ACE_DEBUG ((LM_DEBUG, "\nImpl Limit exception when connecting consumer\n")); } ACE_CATCHANY { - if (TAO_debug_level) ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Exception in connecting consumer \n"); + "\nError: Exception in connecting consumer \n"); } ACE_ENDTRY; } @@ -500,24 +474,15 @@ main (int argc, char* argv[]) ACE_TRY_NEW_ENV { - test.init (argc, - argv - ACE_ENV_ARG_PARAMETER); + test.init (argc, argv ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; test.run_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; } - ACE_CATCH (CORBA::UserException, ue) - { - ACE_PRINT_EXCEPTION (ue, - "Events user error: "); - return 1; - } - ACE_CATCH (CORBA::SystemException, se) + ACE_CATCH (CORBA::Exception, se) { - ACE_PRINT_EXCEPTION (se, - "Events system error: "); + ACE_PRINT_EXCEPTION (se, "Error: "); return 1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/tests/Notify/Basic/AdminProperties.h b/TAO/orbsvcs/tests/Notify/Basic/AdminProperties.h index 5090fa15f31..44abf483bf7 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/AdminProperties.h +++ b/TAO/orbsvcs/tests/Notify/Basic/AdminProperties.h @@ -97,26 +97,23 @@ public: AdminProperties (void); ~AdminProperties (void); - int parse_args (int argc, - char *argv[]) ; + int parse_args (int argc, char *argv[]) ; - int init (int argc, - char *argv [] - ACE_ENV_ARG_DECL); // Initialization. void run_test (ACE_ENV_SINGLE_ARG_DECL); // Run the test. -protected: +private: void create_suppliers (ACE_ENV_SINGLE_ARG_DECL); void create_consumers (ACE_ENV_SINGLE_ARG_DECL); + void create_channel(bool reject ACE_ENV_ARG_DECL); /// Test MaxSuppliers and MaxConsumers void test_max_clients (ACE_ENV_SINGLE_ARG_DECL); /// Test MaxQueueLength properties - void test_max_queue_length (ACE_ENV_SINGLE_ARG_DECL); + void test_max_queue_length (bool reject ACE_ENV_ARG_DECL); // Data Members CosNotifyChannelAdmin::EventChannel_var ec_; @@ -134,12 +131,6 @@ protected: CORBA::Boolean reject_new_events_; // Values for Admin Properties supplied by user. - /// Consumer Delay. - ACE_Time_Value consumer_delay_; - - /// Inital delay. - ACE_Time_Value initial_delay_; - /// Number of consumers to connect to check MaxConsumers property. CORBA::Long consumers_; @@ -155,9 +146,8 @@ protected: /// Count of consumers successfully connect to the EC. int consumers_connected_count_; - /// Boolean flag that is set if the IMPL_LIMIT exception is thrown when trying to - /// exceed the Max_Queue_Length - CORBA::Boolean was_rejected_; + // Number of supplier pushes that resulted in an IMP_LIMIT exception + int rejections_; }; #endif /* ADMINPROPERTIES */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/ConnectDisconnect.cpp b/TAO/orbsvcs/tests/Notify/Basic/ConnectDisconnect.cpp index d66d372563f..f82175451cb 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/ConnectDisconnect.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/ConnectDisconnect.cpp @@ -47,9 +47,9 @@ ConnectDisconnect::ConnectDisconnect (void) any_supplier_ (0), structured_supplier_ (0), sequence_supplier_ (0), - count_ (10), - consumers_ (10), - suppliers_ (10) + count_ (3), + consumers_ (3), + suppliers_ (3) { } @@ -111,8 +111,6 @@ ConnectDisconnect::init (int argc, // How many are we counting..? this->expected_count_ = count_ * (consumers_ * 3 + suppliers_ * 3); - // this->expected_count_ = 10*(10*2 + 0); - // Create the consumers and suppliers. // Arrays of Consumers. @@ -137,6 +135,7 @@ ConnectDisconnect::init (int argc, TAO_Notify_Tests_SequencePushSupplier*[this->suppliers_], -1); + consumer_start( 0 ); return 0; } @@ -153,19 +152,16 @@ ConnectDisconnect::parse_args(int argc, char *argv[]) if ((current_arg = arg_shifter.get_the_parameter ("-count"))) { this->count_ = ACE_OS::atoi (current_arg); - // The number of counsumers to create. arg_shifter.consume_arg (); } else if ((current_arg = arg_shifter.get_the_parameter ("-consumers"))) { this->consumers_ = ACE_OS::atoi (current_arg); - // The number of suppliers to create. arg_shifter.consume_arg (); } else if ((current_arg = arg_shifter.get_the_parameter ("-suppliers"))) { this->suppliers_ = ACE_OS::atoi (current_arg); - // The number of iterations to connect disconnect. arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp ("-?") == 0) @@ -325,28 +321,22 @@ ConnectDisconnect::run_test (ACE_ENV_SINGLE_ARG_DECL) void ConnectDisconnect::end_test (ACE_ENV_SINGLE_ARG_DECL) { - this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + consumer_done( 0 ); } int ConnectDisconnect::check_results (void) { - ACE_DEBUG ((LM_DEBUG, - "result_count_ = %d", - this->result_count_.value ())); - ACE_DEBUG ((LM_DEBUG, - " expected_count_ = %d\n", - this->expected_count_)); + ACE_DEBUG ((LM_DEBUG, "result_count_ = %d", this->result_count_.value ())); + ACE_DEBUG ((LM_DEBUG, " expected_count_ = %d\n", this->expected_count_)); if (this->result_count_ != this->expected_count_) { - ACE_DEBUG ((LM_DEBUG, - "ConnectDisconnect test failed\n")); + ACE_DEBUG ((LM_DEBUG, "ConnectDisconnect test failed\n")); } else { - ACE_DEBUG ((LM_DEBUG, - "ConnectDisconnect test succeded\n")); + ACE_DEBUG ((LM_DEBUG, "ConnectDisconnect test succeeded\n")); } // Destroy the channel. @@ -371,9 +361,7 @@ main (int argc, char* argv[]) ACE_TRY_NEW_ENV { - client.init (argc, - argv - ACE_ENV_ARG_PARAMETER); + client.init (argc, argv ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; client.run_test (ACE_ENV_SINGLE_ARG_PARAMETER); @@ -382,16 +370,9 @@ main (int argc, char* argv[]) client.end_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; } - ACE_CATCH (CORBA::UserException, ue) + ACE_CATCH (CORBA::Exception, se) { - ACE_PRINT_EXCEPTION (ue, - "ConnectDisconnect user error: "); - return 1; - } - ACE_CATCH (CORBA::SystemException, se) - { - ACE_PRINT_EXCEPTION (se, - "ConnectDisconnect system error: "); + ACE_PRINT_EXCEPTION (se, "Error: "); return 1; } ACE_ENDTRY; @@ -399,11 +380,3 @@ main (int argc, char* argv[]) return client.check_results (); } - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - - -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/ConnectDisconnect.h b/TAO/orbsvcs/tests/Notify/Basic/ConnectDisconnect.h index a08cd5dd3ad..eb98ba33e2b 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/ConnectDisconnect.h +++ b/TAO/orbsvcs/tests/Notify/Basic/ConnectDisconnect.h @@ -25,7 +25,9 @@ #include "Notify_SequencePushSupplier.h" #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) #pragma warning(push) +#endif /* _MSC_VER >= 1200 */ #pragma warning(disable:4250) #endif /* _MSC_VER */ @@ -129,7 +131,7 @@ protected: /***************************************************************************/ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma warning(pop) #endif /* _MSC_VER */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/Events.cpp b/TAO/orbsvcs/tests/Notify/Basic/Events.cpp index d75a23f4404..4f818fad8a9 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Events.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/Events.cpp @@ -139,6 +139,8 @@ Events::init (int argc, ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); + consumer_start( 0 ); + return 0; } @@ -292,7 +294,7 @@ Events::run_test (ACE_ENV_SINGLE_ARG_DECL) void Events::end_test (ACE_ENV_SINGLE_ARG_DECL) { - this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + consumer_done( 0 ); } int @@ -339,18 +341,12 @@ main (int argc, char* argv[]) events.run_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - events.ORB_run (); - } - ACE_CATCH (CORBA::UserException, ue) - { - ACE_PRINT_EXCEPTION (ue, - "Events user error: "); - return 1; + events.ORB_run( ACE_ENV_SINGLE_ARG_PARAMETER ); + ACE_TRY_CHECK; } - ACE_CATCH (CORBA::SystemException, se) + ACE_CATCH (CORBA::Exception, se) { - ACE_PRINT_EXCEPTION (se, - "Events system error: "); + ACE_PRINT_EXCEPTION (se, "Error: "); return 1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/tests/Notify/Basic/Events.h b/TAO/orbsvcs/tests/Notify/Basic/Events.h index e7493489b67..1c2ad251bcb 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Events.h +++ b/TAO/orbsvcs/tests/Notify/Basic/Events.h @@ -22,7 +22,9 @@ #include "Notify_StructuredPushSupplier.h" #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) #pragma warning(push) +#endif /* _MSC_VER >= 1200 */ #pragma warning(disable:4250) #endif /* _MSC_VER */ @@ -125,7 +127,7 @@ private: /***************************************************************************/ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma warning(pop) #endif /* _MSC_VER */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/Filter.cpp b/TAO/orbsvcs/tests/Notify/Basic/Filter.cpp index 0cf0b43eae4..6a93dd7bf8b 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Filter.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/Filter.cpp @@ -237,16 +237,9 @@ main (int argc, char* argv[]) events.run_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; } - ACE_CATCH (CORBA::UserException, ue) + ACE_CATCH (CORBA::Exception, se) { - ACE_PRINT_EXCEPTION (ue, - "Events user error: "); - return 1; - } - ACE_CATCH (CORBA::SystemException, se) - { - ACE_PRINT_EXCEPTION (se, - "Events system error: "); + ACE_PRINT_EXCEPTION (se, "Error: "); return 1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/tests/Notify/Basic/Filter.h b/TAO/orbsvcs/tests/Notify/Basic/Filter.h index 9bd93156d6d..a0f6e83f80b 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Filter.h +++ b/TAO/orbsvcs/tests/Notify/Basic/Filter.h @@ -21,7 +21,9 @@ #include "Notify_PushSupplier.h" #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) #pragma warning(push) +#endif /* _MSC_VER >= 1200 */ #pragma warning(disable:4250) #endif /* _MSC_VER */ @@ -85,7 +87,7 @@ protected: /***************************************************************************/ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma warning(pop) #endif /* _MSC_VER */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/IdAssignment.cpp b/TAO/orbsvcs/tests/Notify/Basic/IdAssignment.cpp index d6e52a015d8..ebfd98f3df1 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/IdAssignment.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/IdAssignment.cpp @@ -7,8 +7,8 @@ #include "orbsvcs/CosNotifyCommC.h" #include "IdAssignment.h" -ACE_RCSID (Notify_Tests, - IdAssignment, +ACE_RCSID (Notify_Tests, + IdAssignment, "$Id$") IdAssignment::IdAssignment (void) @@ -478,8 +478,7 @@ int main (int argc, char* argv[]) } ACE_CATCHANY { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Caught exception:"); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Error: "); return 1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/tests/Notify/Basic/LifeCycle.cpp b/TAO/orbsvcs/tests/Notify/Basic/LifeCycle.cpp index 4f48407b6af..0bb420600c7 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/LifeCycle.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/LifeCycle.cpp @@ -9,8 +9,8 @@ #include "LifeCycle.h" -ACE_RCSID (Notify_Tests, - LifeCycle, +ACE_RCSID (Notify_Tests, + LifeCycle, "$Id$") LifeCycle::LifeCycle (void) @@ -260,22 +260,9 @@ main (int argc, char *argv[]) test.run_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; } - ACE_CATCH(CosNotification::UnsupportedAdmin, ex) - { - ACE_PRINT_EXCEPTION (ex, "Unsupported Admin Properties"); - } - ACE_CATCH(CosNotification::UnsupportedQoS, ex) - { - ACE_PRINT_EXCEPTION (ex, "Unsupported QoS Properties"); - } - ACE_CATCH(CosNotifyChannelAdmin::AdminNotFound, ex) - { - ACE_PRINT_EXCEPTION (ex, "destroying admin object"); - } ACE_CATCHANY { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Caught exception:"); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Error: "); return 1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/tests/Notify/Basic/MultiTypes.cpp b/TAO/orbsvcs/tests/Notify/Basic/MultiTypes.cpp index 275567eab72..0e438e75142 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/MultiTypes.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/MultiTypes.cpp @@ -98,7 +98,12 @@ MultiTypes::on_received_event (MultiTypes_PushConsumer* consumer) ACE_DECLARE_NEW_CORBA_ENV; if (disconnect_on_last_event_ == 1) + { consumer->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, "PushConsumer has been disconnected.\n")); + consumer = 0; + } } void @@ -112,7 +117,12 @@ MultiTypes::on_received_event (MultiTypes_StructuredPushConsumer* consumer) ACE_DECLARE_NEW_CORBA_ENV; if (disconnect_on_last_event_ == 1) + { consumer->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, "StructuredPushConsumer has been disconnected.\n")); + consumer = 0; + } } void @@ -126,7 +136,12 @@ MultiTypes::on_received_event (MultiTypes_SequencePushConsumer* consumer) ACE_DECLARE_NEW_CORBA_ENV; if (disconnect_on_last_event_ == 1) + { consumer->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, "SequencePushConsumer has been disconnected.\n")); + consumer = 0; + } } int @@ -210,42 +225,15 @@ MultiTypes::init (int argc, sequence_supplier_->connect (this->supplier_admin_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); + consumer_start( 0 ); + return 0; } int -MultiTypes::parse_args(int argc, char *argv[]) +MultiTypes::parse_args(int, char **) { - ACE_Arg_Shifter arg_shifter (argc, - argv); - - const char *current_arg = 0; - - while (arg_shifter.is_anything_left ()) - { - if ((current_arg = arg_shifter.get_the_parameter ("-count"))) - { - // The number of counsumers to create. - arg_shifter.consume_arg (); - } - else if (arg_shifter.cur_arg_strncasecmp ("-?") == 0) - { - ACE_DEBUG((LM_DEBUG, - "usage: %s " - "-count testcount \n", - argv[0], - argv[0])); - - arg_shifter.consume_arg (); - - return -1; - } - else - { - arg_shifter.ignore_arg (); - } - } - + // Doesn't accept any arguments return 0; } @@ -276,7 +264,7 @@ MultiTypes::run_test (ACE_ENV_SINGLE_ARG_DECL) ACE_CHECK; if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Waiting for consumers to receive the event..\n")); + ACE_DEBUG ((LM_DEBUG, "Waiting for consumers to receive the 1 event..\n")); this->wait_for_all_consumers (1); /*****************************************************************************/ @@ -298,7 +286,7 @@ MultiTypes::run_test (ACE_ENV_SINGLE_ARG_DECL) ACE_CHECK; if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Waiting for consumers to receive the event..\n")); + ACE_DEBUG ((LM_DEBUG, "Waiting for consumers to receive the 1 event..\n")); this->wait_for_all_consumers (1); /*****************************************************************************/ @@ -326,7 +314,7 @@ MultiTypes::run_test (ACE_ENV_SINGLE_ARG_DECL) ACE_CHECK; if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Waiting for consumers to receive the event..\n")); + ACE_DEBUG ((LM_DEBUG, "Waiting for consumers to receive the 2 events..\n")); this->wait_for_all_consumers (2); /*****************************************************************************/ @@ -344,7 +332,7 @@ MultiTypes::run_test (ACE_ENV_SINGLE_ARG_DECL) ACE_CHECK; if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Waiting for consumers to receive the event..\n")); + ACE_DEBUG ((LM_DEBUG, "Waiting for consumers to receive the 1 event..\n")); this->wait_for_all_consumers (1); ACE_DEBUG ((LM_DEBUG, "MultiTypes test has run successfully!\n")); @@ -353,25 +341,24 @@ MultiTypes::run_test (ACE_ENV_SINGLE_ARG_DECL) void MultiTypes::wait_for_all_consumers (int expected_count_per_consumer) { - while (1) + while (true) { - if (any_event_count_.value () == expected_count_per_consumer && - struct_event_count_.value () == expected_count_per_consumer && - seq_event_count_.value () == expected_count_per_consumer) - break; - + if (any_event_count_.value () >= expected_count_per_consumer && + struct_event_count_.value () >= expected_count_per_consumer && + seq_event_count_.value () >= expected_count_per_consumer) { - ACE_Time_Value tv (0,1000); - if (this->orb_->work_pending (tv)) - this->orb_->perform_work (); + break; } + + ACE_Time_Value tv (0, 100 * 1000); + this->orb_->run(tv); } } void MultiTypes::end_test (ACE_ENV_SINGLE_ARG_DECL) { - this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + consumer_done( 0 ); } int @@ -410,28 +397,12 @@ main (int argc, char* argv[]) client.end_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; } - ACE_CATCH (CORBA::UserException, ue) + ACE_CATCH (CORBA::Exception, se) { - ACE_PRINT_EXCEPTION (ue, - "MultiTypes user error: "); - return 1; - } - ACE_CATCH (CORBA::SystemException, se) - { - ACE_PRINT_EXCEPTION (se, - "MultiTypes system error: "); + ACE_PRINT_EXCEPTION (se, "Error: "); return 1; } ACE_ENDTRY; return client.check_results (); } - - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - - -#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/MultiTypes.h b/TAO/orbsvcs/tests/Notify/Basic/MultiTypes.h index ac2701e61b8..6b3ff26a83a 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/MultiTypes.h +++ b/TAO/orbsvcs/tests/Notify/Basic/MultiTypes.h @@ -25,7 +25,9 @@ #include "Notify_SequencePushSupplier.h" #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) #pragma warning(push) +#endif /* _MSC_VER >= 1200 */ #pragma warning(disable:4250) #endif /* _MSC_VER */ @@ -162,7 +164,7 @@ protected: /***************************************************************************/ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma warning(pop) #endif /* _MSC_VER */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/Sequence.cpp b/TAO/orbsvcs/tests/Notify/Basic/Sequence.cpp index 8eed8e3683d..f5276b25cfc 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Sequence.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/Sequence.cpp @@ -141,6 +141,8 @@ Sequence::init (int argc, ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); + consumer_start( 0 ); + return 0; } @@ -324,7 +326,7 @@ Sequence::run_test (ACE_ENV_SINGLE_ARG_DECL) void Sequence::end_test (ACE_ENV_SINGLE_ARG_DECL) { - this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + consumer_done( 0 ); } int @@ -371,18 +373,12 @@ main (int argc, char* argv[]) events.run_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - events.ORB_run (); - } - ACE_CATCH (CORBA::UserException, ue) - { - ACE_PRINT_EXCEPTION (ue, - "Sequence user error: "); - return 1; + events.ORB_run( ACE_ENV_SINGLE_ARG_PARAMETER ); + ACE_TRY_CHECK; } - ACE_CATCH (CORBA::SystemException, se) + ACE_CATCH (CORBA::Exception, se) { - ACE_PRINT_EXCEPTION (se, - "Sequence system error: "); + ACE_PRINT_EXCEPTION (se, "Error: "); return 1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/tests/Notify/Basic/Sequence.h b/TAO/orbsvcs/tests/Notify/Basic/Sequence.h index 5a8e1138f3b..19352ec0150 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Sequence.h +++ b/TAO/orbsvcs/tests/Notify/Basic/Sequence.h @@ -22,7 +22,9 @@ #include "orbsvcs/TimeBaseC.h" #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) #pragma warning(push) +#endif /* _MSC_VER >= 1200 */ #pragma warning(disable:4250) #endif /* _MSC_VER */ @@ -135,7 +137,7 @@ private: /***************************************************************************/ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma warning(pop) #endif /* _MSC_VER */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/Simple.cpp b/TAO/orbsvcs/tests/Notify/Basic/Simple.cpp index 85a1fd75b2d..2e637bd4b47 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Simple.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/Simple.cpp @@ -118,7 +118,7 @@ Simple_Test::init (int argc, ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - ACE_CHECK_RETURN (-1); + consumer_start( 0 ); return 0; } @@ -210,7 +210,7 @@ Simple_Test::run_test (ACE_ENV_SINGLE_ARG_DECL) void Simple_Test::end_test (ACE_ENV_SINGLE_ARG_DECL) { - this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + consumer_done( 0 ); } int @@ -257,18 +257,12 @@ main (int argc, char* argv[]) events.run_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - events.ORB_run (); - } - ACE_CATCH (CORBA::UserException, ue) - { - ACE_PRINT_EXCEPTION (ue, - "Events user error: "); - return 1; + events.ORB_run( ACE_ENV_SINGLE_ARG_PARAMETER ); + ACE_TRY_CHECK; } - ACE_CATCH (CORBA::SystemException, se) + ACE_CATCH (CORBA::Exception, se) { - ACE_PRINT_EXCEPTION (se, - "Events system error: "); + ACE_PRINT_EXCEPTION (se, "Error: "); return 1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/tests/Notify/Basic/Simple.h b/TAO/orbsvcs/tests/Notify/Basic/Simple.h index a941fcfb027..93fb9b9ef5e 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Simple.h +++ b/TAO/orbsvcs/tests/Notify/Basic/Simple.h @@ -21,7 +21,9 @@ #include "Notify_PushSupplier.h" #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) #pragma warning(push) +#endif /* _MSC_VER >= 1200 */ #pragma warning(disable:4250) #endif /* _MSC_VER */ @@ -123,7 +125,7 @@ private: /***************************************************************************/ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma warning(pop) #endif /* _MSC_VER */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/Updates.cpp b/TAO/orbsvcs/tests/Notify/Basic/Updates.cpp index 0646e37a59e..b5d396e3808 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Updates.cpp +++ b/TAO/orbsvcs/tests/Notify/Basic/Updates.cpp @@ -184,10 +184,8 @@ Updates::wait_for_updates (int expected_added, int expected_removed) removed_count_ == expected_removed) break; - { - if (this->orb_->work_pending ()) - this->orb_->perform_work (); - } + ACE_Time_Value tv(0, 100 * 1000); + orb_->run(tv); } } @@ -479,16 +477,9 @@ main (int argc, char* argv[]) updates.run_test (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; } - ACE_CATCH (CORBA::UserException, ue) - { - ACE_PRINT_EXCEPTION (ue, - "Updates user error: "); - return 1; - } ACE_CATCH (CORBA::SystemException, se) { - ACE_PRINT_EXCEPTION (se, - "Updates system error: "); + ACE_PRINT_EXCEPTION (se, "Error: "); return 1; } ACE_ENDTRY; diff --git a/TAO/orbsvcs/tests/Notify/Basic/Updates.h b/TAO/orbsvcs/tests/Notify/Basic/Updates.h index e4c7104f9bf..20ebbc6bcb8 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/Updates.h +++ b/TAO/orbsvcs/tests/Notify/Basic/Updates.h @@ -22,7 +22,9 @@ #include "Notify_StructuredPushSupplier.h" #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) #pragma warning(push) +#endif /* _MSC_VER >= 1200 */ #pragma warning(disable:4250) #endif /* _MSC_VER */ @@ -141,7 +143,7 @@ private: /***************************************************************************/ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #pragma warning(pop) #endif /* _MSC_VER */ diff --git a/TAO/orbsvcs/tests/Notify/Basic/adminproperties.conf b/TAO/orbsvcs/tests/Notify/Basic/adminproperties.conf index d0f06676cb4..7ed22785ab7 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/adminproperties.conf +++ b/TAO/orbsvcs/tests/Notify/Basic/adminproperties.conf @@ -1,4 +1,6 @@ ## $Id$ ## Load the static Cos Notification Service -static Client_Strategy_Factory "-ORBClientConnectionHandler RW" +## We must use the following settings, because the supplier and consumer are co-located, and +## the test needs to prevent the threads from mixing during upcalls. +static Client_Strategy_Factory "-ORBWaitStrategy RW -ORBTransportMuxStrategy exclusive" diff --git a/TAO/orbsvcs/tests/Notify/Basic/notify.mt.conf b/TAO/orbsvcs/tests/Notify/Basic/notify.mt.conf index d9f7dbeb983..1ed64ed8d98 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/notify.mt.conf +++ b/TAO/orbsvcs/tests/Notify/Basic/notify.mt.conf @@ -1,2 +1,2 @@ ##$Id$ -static Notify_Default_Event_Manager_Objects_Factory "-MTDispatching -DispatchingThreads 1" +static Notify_Default_Event_Manager_Objects_Factory "-DispatchingThreads 2" diff --git a/TAO/orbsvcs/tests/Notify/Basic/notify.rt.conf b/TAO/orbsvcs/tests/Notify/Basic/notify.rt.conf index 70abb0d32cd..50faf80e5ee 100644 --- a/TAO/orbsvcs/tests/Notify/Basic/notify.rt.conf +++ b/TAO/orbsvcs/tests/Notify/Basic/notify.rt.conf @@ -1,5 +1,5 @@ dynamic TAO_RT_ORB_Loader Service_Object *TAO_RTCORBA:_make_TAO_RT_ORB_Loader () "-ORBPriorityMapping continuous" - +# # Uncomment this line to use SCHED_FIFO #dynamic TAO_RT_ORB_Loader Service_Object *TAO_RTCORBA:_make_TAO_RT_ORB_Loader () "-ORBSchedPolicy SCHED_FIFO -ORBScopePolicy SYSTEM -ORBPriorityMapping continuous" dynamic TAO_Notify_Service Service_Object * TAO_RT_Notification:_make_TAO_RT_Notify_Service () ""
\ No newline at end of file diff --git a/TAO/orbsvcs/tests/Notify/Basic/run_test.pl b/TAO/orbsvcs/tests/Notify/Basic/run_test.pl index 79a85b158eb..683f9c24930 100755 --- a/TAO/orbsvcs/tests/Notify/Basic/run_test.pl +++ b/TAO/orbsvcs/tests/Notify/Basic/run_test.pl @@ -23,6 +23,7 @@ $status = 0; { name => "ConnectDisconnect", args => "", + extra => 300, }, { name => "Events", @@ -78,9 +79,7 @@ $Naming = new PerlACE::Process ("../../../Naming_Service/Naming_Service", "-o $namingior"); unlink $namingior; -if ($Naming->Spawn () == -1) { - exit 1; -} +$Naming->Spawn (); if (PerlACE::waitforfile_timed ($namingior, $startup_timeout) == -1) { print STDERR "ERROR: waiting for the naming service to start\n"; @@ -98,20 +97,20 @@ for $config (@test_configs) "-ORBSvcConf $config"); unlink $notifyior; $Notification->Spawn (); - + if (PerlACE::waitforfile_timed ($notifyior, $startup_timeout) == -1) { print STDERR "ERROR: waiting for the notify service to start\n"; $Notification->Kill (); $Naming->Kill (); exit 1; } - + for $name (@tests) { ## The MaxQueueLength and MaxEventsPerConsumer are not supported in the Reactive ## configuration, so we skip this test for now. ## The Notification should actually throw an exception for the property not supported. - if ($name->{name} eq "AdminProperties" + if ($name->{name} eq "AdminProperties" && ($config eq "notify.reactive.conf" || $config eq "notify.rt.conf")) { next; @@ -123,15 +122,17 @@ for $config (@test_configs) "$name->{args} "); $test->Spawn (); - $status = $test->WaitKill ($experiment_timeout); + $status = $test->WaitKill ($experiment_timeout + + (defined $name->{extra} ? + $name->{extra} : 0)); - if ($status != 0) + if ($status != 0) { - print STDERR "ERROR: $name returned $status\n"; + print STDERR "ERROR: $name->{name} returned $status\n"; break; } } - + $Notification->Kill (); } diff --git a/TAO/orbsvcs/tests/Notify/Blocking/Notify_Structured_Push_Consumer.cpp b/TAO/orbsvcs/tests/Notify/Blocking/Notify_Structured_Push_Consumer.cpp index 475e5719d0d..3e7c1986bb9 100644 --- a/TAO/orbsvcs/tests/Notify/Blocking/Notify_Structured_Push_Consumer.cpp +++ b/TAO/orbsvcs/tests/Notify/Blocking/Notify_Structured_Push_Consumer.cpp @@ -2,21 +2,25 @@ #include "ace/OS_NS_unistd.h" #include "Notify_Structured_Push_Consumer.h" +#include "Notify_Test_Client.h" #include "orbsvcs/Notify/Notify_Extensions.h" #include "common.h" #include "tao/debug.h" +static const int CONSUMER_DELAY = 1; // seconds. + Notify_Structured_Push_Consumer::Notify_Structured_Push_Consumer ( const char* name, TimeBase::TimeT block, unsigned int expected, - CORBA::Boolean& done) + Notify_Test_Client& client) : name_ (name), blocking_timeout_ (block), expected_ (expected), count_ (0), - done_ (done) + client_ (client) { + this->client_.consumer_start (this); } @@ -44,8 +48,25 @@ Notify_Structured_Push_Consumer::_connect ( CosNotification::QoSProperties properties (2); properties.length (2); + // The discard policy and admin properties tests already test using + // the MaxQueueLength policy, so we'll use MEPC instead. It should + // make no difference. + // If the blocking timeout is less than CONSUMER_DELAY seconds, then + // we want to ensure that exactly one event is discarded, so we set + // the MEPC to expected_ - 1. If the supplier sends 20, then we expect 19, + // and we set MEPC to 18. The first event will be dispatched at once, but + // will block in the consumer. This will allow the queue in the notify svc + // to fill up to 18. However, the blocking code will timeout before the + // consumer finishes which will cause an event to be discarded. This will + // allow the last event to be queued. Eventually the consumer will unblock + // and receive the remaining events properties[0].name = CORBA::string_dup (CosNotification::MaxEventsPerConsumer); - properties[0].value <<= (CORBA::Long)10; + if (blocking_timeout_ < CONSUMER_DELAY * 1000 * 1000 * 10) + properties[0].value <<= (CORBA::Long) expected_ - 1; + else + properties[0].value <<= (CORBA::Long) 10; + + properties[1].name = CORBA::string_dup (TAO_Notify_Extensions::BlockingPolicy); properties[1].value <<= this->blocking_timeout_; @@ -62,48 +83,34 @@ Notify_Structured_Push_Consumer::_connect ( void Notify_Structured_Push_Consumer::push_structured_event ( - const CosNotification::StructuredEvent& event - ACE_ENV_ARG_DECL_NOT_USED /*ACE_ENV_SINGLE_ARG_PARAMETER*/) + const CosNotification::StructuredEvent& event + ACE_ENV_ARG_DECL_NOT_USED /*ACE_ENV_SINGLE_ARG_PARAMETER*/) ACE_THROW_SPEC ((CORBA::SystemException)) { - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, "Received event:\n")); - - CORBA::ULong hlength = event.header.variable_header.length (); - for (CORBA::ULong hi = 0; hi < hlength; hi++) - { - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - "%s = %s\n", - (const char*)event.header.variable_header[hi].name, - Any_String (event.header.variable_header[hi].value))); - } - CORBA::ULong flength = event.filterable_data.length (); - for (CORBA::ULong i = 0; i < flength; i++) - { - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - "%s = %s\n", - (const char*)event.filterable_data[i].name, - Any_String (event.filterable_data[i].value))); - } - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - "-------------------------\n")); + ACE_DEBUG((LM_DEBUG, "-")); + ACE_UNUSED_ARG(event); + this->count_++; if (this->count_ > this->expected_) - { - this->done_ = 1; - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Structured Consumer (%P|%t): ERROR: too " - "many events received.\n"))); - } - else if (this->count_ == this->expected_) - { - this->done_ = 1; - } - else - { - ACE_OS::sleep (1); - } + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Structured Consumer (%P|%t): ERROR: too " + "many events received.\n"))); + } + + if (this->count_ >= this->expected_) + { + ACE_DEBUG((LM_DEBUG, "\nConsumer received %u events.\n", count_)); + this->client_.consumer_done (this); + } + + // By pausing here, we force the channel to back up, which will + // either result in discarding of events, or blocking, depending + // on whether our BlockingPolicy is greater than the following + // delay time. + // A BlockingPolicy > 1 second should allow the first event. + // A BlockingPolicy < 1 second should discard the first event. + if (count_ == 1) + ACE_OS::sleep (CONSUMER_DELAY); } + diff --git a/TAO/orbsvcs/tests/Notify/Blocking/Notify_Structured_Push_Consumer.h b/TAO/orbsvcs/tests/Notify/Blocking/Notify_Structured_Push_Consumer.h index 8041f156b35..502c28c924d 100644 --- a/TAO/orbsvcs/tests/Notify/Blocking/Notify_Structured_Push_Consumer.h +++ b/TAO/orbsvcs/tests/Notify/Blocking/Notify_Structured_Push_Consumer.h @@ -21,6 +21,8 @@ #include "Notify_StructuredPushConsumer.h" #include "orbsvcs/TimeBaseC.h" +class Notify_Test_Client; + class Notify_Structured_Push_Consumer: public TAO_Notify_Tests_StructuredPushConsumer { public: @@ -28,7 +30,7 @@ public: const char* name, TimeBase::TimeT blocking, unsigned int expected, - CORBA::Boolean& done); + Notify_Test_Client& client); void _connect (CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin ACE_ENV_ARG_DECL) @@ -43,7 +45,7 @@ protected: TimeBase::TimeT blocking_timeout_; unsigned int expected_; unsigned int count_; - CORBA::Boolean& done_; + Notify_Test_Client& client_; }; #endif /* TAO_NOTIFY_STRUCTURED_PUSH_CONSUMER_H */ |