1 #include "ace/Monitor_Point_Registry.h"
3 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
5 #include "ace/Monitor_Base.h"
6 #include "ace/Guard_T.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
12 namespace Monitor_Control
14 Monitor_Point_Registry
*
15 Monitor_Point_Registry::instance ()
18 ACE_Singleton
<Monitor_Point_Registry
, ACE_SYNCH_MUTEX
>::instance ();
22 Monitor_Point_Registry::add (Monitor_Base
* type
)
26 ACELIB_ERROR_RETURN ((LM_ERROR
,
27 "registry add: null type\n"),
34 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX
, guard
, this->mutex_
, false);
38 status
= this->map_
.bind (type
->name (), type
);
43 ACELIB_ERROR_RETURN ((LM_ERROR
,
44 "registry add: map bind failed\n"),
52 Monitor_Point_Registry::remove (const char* name
)
56 ACELIB_ERROR_RETURN ((LM_ERROR
,
57 "registry remove: null name\n"),
62 Map::data_type mp
= 0;
65 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX
, guard
, this->mutex_
, false);
67 ACE_CString
name_str (name
, 0, false);
68 status
= this->map_
.unbind (name_str
, mp
);
73 // (JP) There is a problem with this failing on a single ACE_Message_Queue
74 // monitor per process. I think it is the message queue associated
75 // with the default reactor, maybe because at that low level, ACE
76 // is using malloc with placement, then free, which may bypass the
77 // normal destructors. In any case, it happens only at shutdown
78 // and there seems to be no memory leak.
79 // ACELIB_ERROR_RETURN ((LM_ERROR,
80 // "registry remove: unbind failed for %s\n",
92 Monitor_Control_Types::NameList
93 Monitor_Point_Registry::names ()
95 Monitor_Control_Types::NameList name_holder_
;
98 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX
, guard
, this->mutex_
, 0);
100 for (Map::CONST_ITERATOR
i (this->map_
); !i
.done (); i
.advance ())
102 name_holder_
.push_back (i
->key ());
110 Monitor_Point_Registry::get (const ACE_CString
& name
) const
112 Map::data_type mp
= 0;
115 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX
, guard
, this->mutex_
, 0);
117 this->map_
.find (name
, mp
);
129 Monitor_Point_Registry::constraint_id ()
134 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX
, guard
, this->mutex_
, -1);
136 retval
= this->constraint_id_
++;
143 Monitor_Point_Registry::cleanup ()
145 for (Map::ITERATOR i
= this->map_
.begin ();
146 i
!= this->map_
.end ();
149 Map::ENTRY
* entry
= 0;
151 entry
->int_id_
->remove_ref ();
157 ACE_END_VERSIONED_NAMESPACE_DECL
159 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */