1 #include "ace/Monitor_Admin.h"
3 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
5 #include "ace/Reactor.h"
6 #include "ace/Monitor_Point_Registry.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
12 namespace Monitor_Control
15 Monitor_Point_Auto_Updater::handle_timeout (
16 const ACE_Time_Value
& /* current_time */,
17 const void* monitor_point
)
19 const Monitor_Base
* const_mp
=
20 reinterpret_cast<const Monitor_Base
*> (monitor_point
);
21 Monitor_Base
* mp
= const_cast<Monitor_Base
*> (const_mp
);
26 //====================================================================
28 Monitor_Admin::Monitor_Admin ()
29 : reactor_ (ACE_Reactor::instance ()),
30 default_reactor_ (true)
33 Monitor_Admin::~Monitor_Admin ()
35 if (this->default_reactor_
)
37 /// Destroys the timers associated with our event handler
38 /// before its destructor is called.
39 ACE_Reactor::instance ()->close_singleton ();
42 /// We access the registry through ACE_Singleton, which
43 /// doesn't call the destructor, so we call this method to
44 /// do a remove_ref() on all monitor points left in the registry.
45 /// which needs to be done before the registry goes away.
46 Monitor_Point_Registry::instance ()->cleanup ();
50 Monitor_Admin::monitor_point (Monitor_Base
* monitor_point
,
51 const ACE_Time_Value
& time
)
53 /// This call checks for a null monitor_point.
55 Monitor_Point_Registry::instance ()->add (monitor_point
);
59 ACELIB_ERROR_RETURN ((LM_ERROR
,
60 "registration of %s failed\n",
61 monitor_point
->name ()),
64 else if (time
!= ACE_Time_Value::zero
)
66 this->reactor_
->schedule_timer (&this->auto_updater_
,
76 Monitor_Admin::monitor_point (const char* name
)
78 ACE_CString
name_str (name
, 0, false);
79 return Monitor_Point_Registry::instance ()->get (name_str
);
83 Monitor_Admin::auto_query (ACE_Event_Handler
* handler
,
85 const ACE_Time_Value
& time
)
87 this->reactor_
->schedule_timer (handler
,
94 Monitor_Admin::reactor (ACE_Reactor
* new_reactor
)
96 this->reactor_
= new_reactor
;
97 this->default_reactor_
= false;
101 Monitor_Admin::reactor () const
103 return this->reactor_
;
108 ACE_END_VERSIONED_NAMESPACE_DECL
110 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */