Public Member Functions | Private Member Functions | Private Attributes

ACE_Dynamic_Service_Dependency Class Reference

Provides a way to declare dependency on specific service, thus helping to avoid order of initialization issues with instances of an objects whose implementation code resides in dynamically loaded services. More...

#include <Dynamic_Service_Dependency.h>

Collaboration diagram for ACE_Dynamic_Service_Dependency:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal)
 ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal)
 ~ACE_Dynamic_Service_Dependency (void)

Private Member Functions

void init (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal)

Private Attributes

ACE_DLL tracker_

Detailed Description

Provides a way to declare dependency on specific service, thus helping to avoid order of initialization issues with instances of an objects whose implementation code resides in dynamically loaded services.

It is disastrous to have dynamically loadable services create and give away ownership of objects and then ending up being unloaded before all those instances have been deleted. Normally the code for such objects classes resides within the TEXT segment of the DLL, which implements the service. If a service gets removed, its DLL may be unmapped from memory and then any attempt to invoke a method on the said objects will cause SEGV.

Such instances must contain a member of ACE_Dynamic_Service_Dependency initialized with the service they depend on. ACE_Dynamic_Service_Dependency's constructor and destructor are "magical" - they work by maintaining the underlying dynamic service's DLL reference count.

Definition at line 50 of file Dynamic_Service_Dependency.h.


Constructor & Destructor Documentation

ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency ( const ACE_Service_Gestalt cfg,
const ACE_TCHAR principal 
)

Definition at line 20 of file Dynamic_Service_Dependency.cpp.

{
  this->init (cfg, principal);
}

ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency ( const ACE_TCHAR principal  ) 
ACE_Dynamic_Service_Dependency::~ACE_Dynamic_Service_Dependency ( void   ) 

Definition at line 27 of file Dynamic_Service_Dependency.cpp.

{
  if (ACE::debug ())
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%P|%t) DSD, this=%@ - destroying\n"),
                this));
}


Member Function Documentation

void ACE_Dynamic_Service_Dependency::init ( const ACE_Service_Gestalt cfg,
const ACE_TCHAR principal 
) [private]

Definition at line 36 of file Dynamic_Service_Dependency.cpp.

{
  const ACE_Service_Type* st =
    ACE_Dynamic_Service_Base::find_i (cfg, principal,false);
  if (ACE::debug ())
    {
      ACE_DEBUG ((LM_DEBUG,
      ACE_TEXT ("(%P|%t) DSD, this=%@ - creating dependency on "), this));
      st->dump ();
    }
  this->tracker_ = st->dll ();
}


Member Data Documentation

Definition at line 62 of file Dynamic_Service_Dependency.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines