Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Thread_Lane_Resources Class Reference

Class representing a thread lane's resources. More...

#include <Thread_Lane_Resources.h>

Collaboration diagram for TAO_Thread_Lane_Resources:

Collaboration graph
[legend]
List of all members.

Accessors

TAO_Acceptor_Registryacceptor_registry (void)
TAO_Connector_Registryconnector_registry (ACE_ENV_SINGLE_ARG_DECL)
TAO_Transport_Cache_Managertransport_cache (void)
TAO_Leader_Followerleader_follower (void)
ACE_Allocatorinput_cdr_dblock_allocator (void)
ACE_Allocatorinput_cdr_buffer_allocator (void)
ACE_Allocatorinput_cdr_msgblock_allocator (void)
ACE_Allocatortransport_message_buffer_allocator (void)

[NOHEADER]

ACE_Allocatorinput_cdr_dblock_allocator_
ACE_Allocatorinput_cdr_buffer_allocator_
ACE_Allocatorinput_cdr_msgblock_allocator_

[NOHEADER]

ACE_Allocatortransport_message_buffer_allocator_

Public Methods

 TAO_Thread_Lane_Resources (TAO_ORB_Core &orb_core, TAO_New_Leader_Generator *new_leader_generator=0)
 Constructor. More...

 ~TAO_Thread_Lane_Resources (void)
 Destructor. More...

int is_collocated (const TAO_MProfile &mprofile)
int open_acceptor_registry (int ignore_address ACE_ENV_ARG_DECL)
 Open the acceptor registry. More...

void finalize (void)
 Finalize resources. More...

void shutdown_reactor (void)
 Shutdown the reactor. More...


Private Methods

int has_acceptor_registry_been_created (void) const
 Checks if the acceptor registry has been created. More...

TAO_Resource_Factoryresource_factory (void)
 Helper to get the resource factory in the ORB_Core. More...


Private Attributes

TAO_ORB_Coreorb_core_
 ORB_Core related to this thread lane. More...

TAO_Acceptor_Registryacceptor_registry_
 The registry which maintains a list of acceptor factories for each loaded protocol. More...

TAO_Connector_Registryconnector_registry_
 The connector registry which all active connectors must register themselves with. More...

TAO_Transport_Cache_Managertransport_cache_
 Transport cache. More...

TAO_Leader_Followerleader_follower_
 The leader/followers management class for this lane. More...

TAO_SYNCH_MUTEX lock_
 Synchronization. More...

TAO_New_Leader_Generatornew_leader_generator_
 Generator of new leader threads. More...


Detailed Description

Class representing a thread lane's resources.

Definition at line 42 of file Thread_Lane_Resources.h.


Constructor & Destructor Documentation

TAO_Thread_Lane_Resources::TAO_Thread_Lane_Resources TAO_ORB_Core   orb_core,
TAO_New_Leader_Generator   new_leader_generator = 0
 

Constructor.

Definition at line 20 of file Thread_Lane_Resources.cpp.

References ACE_NEW.

00022   : orb_core_ (orb_core),
00023     acceptor_registry_ (0),
00024     connector_registry_ (0),
00025     transport_cache_ (0),
00026     leader_follower_ (0),
00027     new_leader_generator_ (new_leader_generator),
00028     input_cdr_dblock_allocator_ (0),
00029     input_cdr_buffer_allocator_ (0),
00030     input_cdr_msgblock_allocator_ (0),
00031     transport_message_buffer_allocator_ (0)
00032 {
00033   // Create the transport cache.
00034   ACE_NEW (this->transport_cache_,
00035            TAO_Transport_Cache_Manager (orb_core));
00036 
00037 }

TAO_Thread_Lane_Resources::~TAO_Thread_Lane_Resources void   
 

Destructor.

Definition at line 39 of file Thread_Lane_Resources.cpp.

00040 {
00041 
00042 }


Member Function Documentation

TAO_Acceptor_Registry & TAO_Thread_Lane_Resources::acceptor_registry void   
 

Definition at line 66 of file Thread_Lane_Resources.cpp.

References acceptor_registry_, ACE_GUARD_RETURN, TAO_Resource_Factory::get_acceptor_registry, orb_core_, TAO_ORB_Core::resource_factory, resource_factory, and TAO_SYNCH_MUTEX.

Referenced by TAO_Tagged_Profile::extract_object_key, is_collocated, open_acceptor_registry, and TAO_IIOP_Transport::set_bidir_context_info.

00067 {
00068   // Double check.
00069   if (this->acceptor_registry_ == 0)
00070     {
00071       // @@todo: Wouldnt this crash big time if you happen to
00072       // dereference a  null-pointer? Needs fixing.
00073       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00074                         ace_mon,
00075                         this->lock_,
00076                         *this->acceptor_registry_);
00077       if (this->acceptor_registry_ == 0)
00078         {
00079           // @@ Not exception safe code
00080           // Get the resource factory.
00081           TAO_Resource_Factory &resource_factory =
00082             *this->orb_core_.resource_factory ();
00083 
00084           // Ask it to create a new acceptor registry.
00085           this->acceptor_registry_ =
00086             resource_factory.get_acceptor_registry ();
00087         }
00088     }
00089 
00090   return *this->acceptor_registry_;
00091 }

TAO_Connector_Registry * TAO_Thread_Lane_Resources::connector_registry ACE_ENV_SINGLE_ARG_DECL   
 

Definition at line 94 of file Thread_Lane_Resources.cpp.

References ACE_ENV_SINGLE_ARG_DECL, ACE_GUARD_RETURN, ACE_THROW_RETURN, connector_registry, connector_registry_, TAO_Resource_Factory::get_connector_registry, TAO_Connector_Registry::open, orb_core_, TAO_ORB_Core::resource_factory, TAO_CONNECTOR_REGISTRY_INIT_LOCATION_CODE, and TAO_SYNCH_MUTEX.

Referenced by connector_registry, and TAO_ORB_Core::connector_registry.

00095 {
00096   // Double check.
00097   if (this->connector_registry_ == 0)
00098     {
00099       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00100                         ace_mon,
00101                         this->lock_,
00102                         0);
00103 
00104       if (this->connector_registry_ == 0)
00105         {
00106           // Ask it to create a new acceptor registry.
00107           TAO_Connector_Registry *connector_registry =
00108             this->orb_core_.resource_factory ()->get_connector_registry ();
00109 
00110           if (connector_registry == 0)
00111             ACE_THROW_RETURN (CORBA::INITIALIZE (
00112                                 CORBA::SystemException::_tao_minor_code (
00113                                   TAO_CONNECTOR_REGISTRY_INIT_LOCATION_CODE,
00114                                   0),
00115                                 CORBA::COMPLETED_NO),
00116                       0);
00117 
00118           if (connector_registry->open (&this->orb_core_) != 0)
00119             ACE_THROW_RETURN (CORBA::INITIALIZE (
00120                                 CORBA::SystemException::_tao_minor_code (
00121                                   TAO_CONNECTOR_REGISTRY_INIT_LOCATION_CODE,
00122                                   0),
00123                                 CORBA::COMPLETED_NO),
00124                               0);
00125 
00126           // Finally, everything is created and opened successfully:
00127           // now we can assign to the member.  Otherwise, the
00128           // assignment would be premature.
00129           this->connector_registry_ =
00130             connector_registry;
00131         }
00132     }
00133 
00134   return this->connector_registry_;
00135 }

void TAO_Thread_Lane_Resources::finalize void   
 

Finalize resources.

Definition at line 247 of file Thread_Lane_Resources.cpp.

References acceptor_registry_, ACE_Unbounded_Set_Iterator::advance, ACE_Event_Handler::ALL_EVENTS_MASK, TAO_Transport_Cache_Manager::close, TAO_Acceptor_Registry::close_all, TAO_Connector_Registry::close_all, connector_registry_, input_cdr_buffer_allocator_, input_cdr_dblock_allocator_, input_cdr_msgblock_allocator_, ACE_Unbounded_Set::is_empty, leader_follower, leader_follower_, ACE_Unbounded_Set_Iterator::next, ACE_Handle_Set::num_set, TAO_Leader_Follower::reactor, ACE_Allocator::remove, ACE_Reactor::remove_handler, transport_cache_, and transport_message_buffer_allocator_.

Referenced by TAO_Default_Thread_Lane_Resources_Manager::finalize.

00248 {
00249   // Close connectors before acceptors!
00250   // Ask the registry to close all registered connectors.
00251   if (this->connector_registry_ != 0)
00252     {
00253       this->connector_registry_->close_all ();
00254       delete this->connector_registry_;
00255     }
00256 
00257   // Ask the registry to close all registered acceptors.
00258   if (this->acceptor_registry_ != 0)
00259     {
00260       this->acceptor_registry_->close_all ();
00261       delete this->acceptor_registry_;
00262     }
00263 
00264   // Set of file descriptors corresponding to open connections.  This
00265   // handle set is used to explicitly deregister the connection event
00266   // handlers from the Reactor.  This is particularly important for
00267   // dynamically loaded ORBs where an application level reactor, such
00268   // as the Singleton reactor, is used instead of an ORB created one.
00269   ACE_Handle_Set handle_set;
00270   TAO_EventHandlerSet unregistered;
00271 
00272   // Close the transport cache and return the handle set that needs
00273   // to be de-registered from the reactor.
00274   this->transport_cache_->close (handle_set, unregistered);
00275 
00276   // Shutdown all open connections that are registered with the ORB
00277   // Core.  Note that the ACE_Event_Handler::DONT_CALL mask is NOT
00278   // used here since the reactor should invoke each handle's
00279   // corresponding ACE_Event_Handler::handle_close() method to ensure
00280   // that the connection is shutdown gracefully prior to destroying
00281   // the ORB Core.
00282   if (handle_set.num_set () > 0)
00283     (void) this->leader_follower ().reactor ()->remove_handler (handle_set,
00284                                                                 ACE_Event_Handler::ALL_EVENTS_MASK);
00285   if (!unregistered.is_empty ())
00286     {
00287       ACE_Event_Handler** eh;
00288       for (TAO_EventHandlerSetIterator iter(unregistered);
00289            iter.next (eh);
00290            iter.advance())
00291         {
00292           (*eh)->handle_close (ACE_INVALID_HANDLE,
00293                                ACE_Event_Handler::ALL_EVENTS_MASK);
00294         }
00295     }
00296 
00297   delete this->transport_cache_;
00298   delete this->leader_follower_;
00299 
00300   // Delete all the allocators here.. They shouldnt be done earlier,
00301   // lest some of the contents in the abve, say reactor or acceptor
00302   // may use memory from the pool..
00303   if (this->input_cdr_dblock_allocator_ != 0)
00304     this->input_cdr_dblock_allocator_->remove ();
00305   delete this->input_cdr_dblock_allocator_;
00306 
00307   if (this->input_cdr_buffer_allocator_ != 0)
00308     this->input_cdr_buffer_allocator_->remove ();
00309   delete this->input_cdr_buffer_allocator_;
00310 
00311   if (this->input_cdr_msgblock_allocator_ != 0)
00312     this->input_cdr_msgblock_allocator_->remove ();
00313   delete this->input_cdr_msgblock_allocator_;
00314 
00315   if (this->transport_message_buffer_allocator_ != 0)
00316     this->transport_message_buffer_allocator_->remove ();
00317   delete this->transport_message_buffer_allocator_;
00318 }

int TAO_Thread_Lane_Resources::has_acceptor_registry_been_created void    const [private]
 

Checks if the acceptor registry has been created.

Definition at line 51 of file Thread_Lane_Resources.cpp.

References acceptor_registry_.

Referenced by is_collocated.

00052 {
00053   return this->acceptor_registry_ != 0;
00054 }

ACE_Allocator * TAO_Thread_Lane_Resources::input_cdr_buffer_allocator void   
 

Definition at line 176 of file Thread_Lane_Resources.cpp.

References ACE_GUARD_RETURN, TAO_Resource_Factory::input_cdr_buffer_allocator, input_cdr_buffer_allocator_, resource_factory, and TAO_SYNCH_MUTEX.

Referenced by TAO_ORB_Core::input_cdr_buffer_allocator.

00177 {
00178   if (this->input_cdr_buffer_allocator_ == 0)
00179     {
00180       // Double checked locking
00181       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
00182       if (this->input_cdr_buffer_allocator_ == 0)
00183         this->input_cdr_buffer_allocator_ =
00184           this->resource_factory ()->input_cdr_buffer_allocator ();
00185     }
00186 
00187   return this->input_cdr_buffer_allocator_;
00188 }

ACE_Allocator * TAO_Thread_Lane_Resources::input_cdr_dblock_allocator void   
 

Definition at line 160 of file Thread_Lane_Resources.cpp.

References ACE_GUARD_RETURN, TAO_Resource_Factory::input_cdr_dblock_allocator, input_cdr_dblock_allocator_, resource_factory, and TAO_SYNCH_MUTEX.

Referenced by TAO_ORB_Core::input_cdr_dblock_allocator.

00161 {
00162   if (this->input_cdr_dblock_allocator_ == 0)
00163     {
00164       // Double checked locking
00165       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
00166       if (this->input_cdr_dblock_allocator_ == 0)
00167         this->input_cdr_dblock_allocator_ =
00168           this->resource_factory ()->input_cdr_dblock_allocator ();
00169     }
00170 
00171   return this->input_cdr_dblock_allocator_;
00172 }

ACE_Allocator * TAO_Thread_Lane_Resources::input_cdr_msgblock_allocator void   
 

Definition at line 192 of file Thread_Lane_Resources.cpp.

References ACE_GUARD_RETURN, TAO_Resource_Factory::input_cdr_msgblock_allocator, input_cdr_msgblock_allocator_, resource_factory, and TAO_SYNCH_MUTEX.

Referenced by TAO_ORB_Core::input_cdr_msgblock_allocator.

00193 {
00194   if (this->input_cdr_msgblock_allocator_ == 0)
00195     {
00196       // Double checked locking
00197       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
00198       if (this->input_cdr_msgblock_allocator_ == 0)
00199         this->input_cdr_msgblock_allocator_ =
00200           this->resource_factory ()->input_cdr_msgblock_allocator ();
00201     }
00202 
00203   return this->input_cdr_msgblock_allocator_;
00204 }

int TAO_Thread_Lane_Resources::is_collocated const TAO_MProfile   mprofile
 

Definition at line 57 of file Thread_Lane_Resources.cpp.

References acceptor_registry, has_acceptor_registry_been_created, and TAO_Acceptor_Registry::is_collocated.

Referenced by TAO_Default_Thread_Lane_Resources_Manager::is_collocated.

00058 {
00059   if (!this->has_acceptor_registry_been_created ())
00060     return 0;
00061 
00062   return this->acceptor_registry ().is_collocated (mprofile);
00063 }

TAO_Leader_Follower & TAO_Thread_Lane_Resources::leader_follower void   
 

Definition at line 139 of file Thread_Lane_Resources.cpp.

References ACE_GUARD_RETURN, ACE_NEW_RETURN, leader_follower_, and TAO_SYNCH_MUTEX.

Referenced by finalize, TAO_ORB_Core::leader_follower, and shutdown_reactor.

00140 {
00141   // Double check.
00142   if (this->leader_follower_ == 0)
00143     {
00144       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, *this->leader_follower_);
00145       if (this->leader_follower_ == 0)
00146         {
00147           // Create a new Leader Follower object.
00148           ACE_NEW_RETURN (this->leader_follower_,
00149                           TAO_Leader_Follower (&this->orb_core_,
00150                                                this->new_leader_generator_),
00151                           *this->leader_follower_);
00152         }
00153     }
00154 
00155   return *this->leader_follower_;
00156 }

int TAO_Thread_Lane_Resources::open_acceptor_registry int ignore_address    ACE_ENV_ARG_DECL
 

Open the acceptor registry.

Definition at line 222 of file Thread_Lane_Resources.cpp.

References acceptor_registry, ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_ENV_ARG_PARAMETER, and TAO_Acceptor_Registry::open.

Referenced by TAO_Default_Thread_Lane_Resources_Manager::open_default_resources.

00224 {
00225   /// Access the acceptor registry.
00226   TAO_Acceptor_Registry &ar =
00227     this->acceptor_registry ();
00228 
00229   // Open it.
00230   int result =
00231     ar.open (&this->orb_core_,
00232              this->leader_follower ().reactor (),
00233              ignore_address
00234               ACE_ENV_ARG_PARAMETER);
00235   ACE_CHECK_RETURN (-1);
00236 
00237   return result;
00238 }

TAO_Resource_Factory * TAO_Thread_Lane_Resources::resource_factory void    [private]
 

Helper to get the resource factory in the ORB_Core.

Definition at line 241 of file Thread_Lane_Resources.cpp.

References orb_core_, and TAO_ORB_Core::resource_factory.

Referenced by acceptor_registry, input_cdr_buffer_allocator, input_cdr_dblock_allocator, input_cdr_msgblock_allocator, and transport_message_buffer_allocator.

00242 {
00243   return this->orb_core_.resource_factory ();
00244 }

void TAO_Thread_Lane_Resources::shutdown_reactor void   
 

Shutdown the reactor.

Definition at line 321 of file Thread_Lane_Resources.cpp.

References ACE_GUARD, ACE_Reactor::end_reactor_event_loop, TAO_Leader_Follower::has_clients, leader_follower, TAO_Leader_Follower::lock, TAO_Leader_Follower::reactor, TAO_SYNCH_MUTEX, and ACE_Reactor::wakeup_all_threads.

Referenced by TAO_Default_Thread_Lane_Resources_Manager::shutdown_reactor.

00322 {
00323   TAO_Leader_Follower &leader_follower =
00324     this->leader_follower ();
00325 
00326   ACE_GUARD (TAO_SYNCH_MUTEX,
00327              ace_mon,
00328              leader_follower.lock ());
00329 
00330   // Wakeup all the threads waiting blocked in the event loop, this
00331   // does not guarantee that they will all go away, but reduces the
00332   // load on the POA....
00333   ACE_Reactor *reactor =
00334     leader_follower.reactor ();
00335 
00336   reactor->wakeup_all_threads ();
00337 
00338   // If there are some client threads running we have to wait until
00339   // they finish, when the last one does it will shutdown the reactor
00340   // for us.  Meanwhile no new requests will be accepted because the
00341   // POA will not process them.
00342   if (!leader_follower.has_clients ())
00343     {
00344       // Wake up all waiting threads in the reactor.
00345       reactor->end_reactor_event_loop ();
00346     }
00347 }

TAO_Transport_Cache_Manager & TAO_Thread_Lane_Resources::transport_cache void   
 

Definition at line 45 of file Thread_Lane_Resources.cpp.

References transport_cache_.

Referenced by TAO_IIOP_Connection_Handler::add_transport_to_cache, TAO_Connector::connect, TAO_IIOP_Connector::make_connection, TAO_Creation_Strategy::make_svc_handler, and TAO_Transport::transport_cache_manager.

00046 {
00047   return *this->transport_cache_;
00048 }

ACE_Allocator * TAO_Thread_Lane_Resources::transport_message_buffer_allocator void   
 

Definition at line 207 of file Thread_Lane_Resources.cpp.

References ACE_GUARD_RETURN, TAO_Resource_Factory::input_cdr_dblock_allocator, resource_factory, TAO_SYNCH_MUTEX, and transport_message_buffer_allocator_.

Referenced by TAO_ORB_Core::transport_message_buffer_allocator.

00208 {
00209   if (this->transport_message_buffer_allocator_ == 0)
00210     {
00211       // Double checked locking
00212       ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
00213       if (this->transport_message_buffer_allocator_ == 0)
00214         this->transport_message_buffer_allocator_ =
00215           this->resource_factory ()->input_cdr_dblock_allocator ();
00216     }
00217 
00218   return this->transport_message_buffer_allocator_;
00219 }


Member Data Documentation

TAO_Acceptor_Registry* TAO_Thread_Lane_Resources::acceptor_registry_ [private]
 

The registry which maintains a list of acceptor factories for each loaded protocol.

Definition at line 115 of file Thread_Lane_Resources.h.

Referenced by acceptor_registry, finalize, and has_acceptor_registry_been_created.

TAO_Connector_Registry* TAO_Thread_Lane_Resources::connector_registry_ [private]
 

The connector registry which all active connectors must register themselves with.

Definition at line 119 of file Thread_Lane_Resources.h.

Referenced by connector_registry, and finalize.

ACE_Allocator* TAO_Thread_Lane_Resources::input_cdr_buffer_allocator_ [private]
 

Definition at line 136 of file Thread_Lane_Resources.h.

Referenced by finalize, and input_cdr_buffer_allocator.

ACE_Allocator* TAO_Thread_Lane_Resources::input_cdr_dblock_allocator_ [private]
 

Definition at line 135 of file Thread_Lane_Resources.h.

Referenced by finalize, and input_cdr_dblock_allocator.

ACE_Allocator* TAO_Thread_Lane_Resources::input_cdr_msgblock_allocator_ [private]
 

Definition at line 137 of file Thread_Lane_Resources.h.

Referenced by finalize, and input_cdr_msgblock_allocator.

TAO_Leader_Follower* TAO_Thread_Lane_Resources::leader_follower_ [private]
 

The leader/followers management class for this lane.

Definition at line 125 of file Thread_Lane_Resources.h.

Referenced by finalize, and leader_follower.

TAO_SYNCH_MUTEX TAO_Thread_Lane_Resources::lock_ [private]
 

Synchronization.

Definition at line 128 of file Thread_Lane_Resources.h.

TAO_New_Leader_Generator* TAO_Thread_Lane_Resources::new_leader_generator_ [private]
 

Generator of new leader threads.

Definition at line 131 of file Thread_Lane_Resources.h.

TAO_ORB_Core& TAO_Thread_Lane_Resources::orb_core_ [private]
 

ORB_Core related to this thread lane.

Definition at line 111 of file Thread_Lane_Resources.h.

Referenced by acceptor_registry, connector_registry, and resource_factory.

TAO_Transport_Cache_Manager* TAO_Thread_Lane_Resources::transport_cache_ [private]
 

Transport cache.

Definition at line 122 of file Thread_Lane_Resources.h.

Referenced by finalize, and transport_cache.

ACE_Allocator* TAO_Thread_Lane_Resources::transport_message_buffer_allocator_ [private]
 

Definition at line 142 of file Thread_Lane_Resources.h.

Referenced by finalize, and transport_message_buffer_allocator.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:42:42 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002