blob: 3eb4e0df7c75988ae74c823ee17f328f60a84da0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// -*- C++ -*-
//=============================================================================
/**
* @file Dynamic_Service_Dependency.h
*
* $Id$
*
* @author Iliyan Jeliazkov <iliyan@ociweb.com>
*/
//=============================================================================
#ifndef ACE_DYNAMIC_SERVICE_DEPENDENCY_H
#define ACE_DYNAMIC_SERVICE_DEPENDENCY_H
#include /**/ "ace/pre.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Dynamic_Service_Base.h"
#include "ace/Service_Object.h"
#include "ace/DLL.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
* @class ACE_Dynamic_Service_Dependency
*
* @brief 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.
*/
class ACE_Export ACE_Dynamic_Service_Dependency
{
public:
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:
void init (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal);
private:
ACE_DLL tracker_;
};
ACE_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
#endif /* ACE_DYNAMIC_SERVICE_DEPENDENCY_H */
|