1 // $Id: Monitor_Admin.cpp 81753 2008-05-21 19:02:47Z parsons $
3 #include "ace/Monitor_Admin.h"
5 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
7 #include "ace/Reactor.h"
8 #include "ace/Monitor_Point_Registry.h"
10 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 namespace Monitor_Control
17 Monitor_Point_Auto_Updater::handle_timeout (
18 const ACE_Time_Value
& /* current_time */,
19 const void* monitor_point
)
21 const Monitor_Base
* const_mp
=
22 reinterpret_cast<const Monitor_Base
*> (monitor_point
);
23 Monitor_Base
* mp
= const_cast<Monitor_Base
*> (const_mp
);
28 //====================================================================
30 Monitor_Admin::Monitor_Admin (void)
31 : reactor_ (ACE_Reactor::instance ()),
32 default_reactor_ (true)
35 Monitor_Admin::~Monitor_Admin (void)
37 if (this->default_reactor_
)
39 /// Destroys the timers associated with our event handler
40 /// before its destructor is called.
41 ACE_Reactor::instance ()->close_singleton ();
44 /// We access the registry through ACE_Singleton, which
45 /// doesn't call the destructor, so we call this method to
46 /// do a remove_ref() on all monitor points left in the registry.
47 /// which needs to be done before the registry goes away.
48 Monitor_Point_Registry::instance ()->cleanup ();
52 Monitor_Admin::monitor_point (Monitor_Base
* monitor_point
,
53 const ACE_Time_Value
& time
)
55 /// This call checks for a null monitor_point.
57 Monitor_Point_Registry::instance ()->add (monitor_point
);
61 ACE_ERROR_RETURN ((LM_ERROR
,
62 "registration of %s failed\n",
63 monitor_point
->name ()),
66 else if (time
!= ACE_Time_Value::zero
)
68 this->reactor_
->schedule_timer (&this->auto_updater_
,
78 Monitor_Admin::monitor_point (const char* name
)
80 ACE_CString
name_str (name
, 0, false);
81 return Monitor_Point_Registry::instance ()->get (name_str
);
85 Monitor_Admin::auto_query (ACE_Event_Handler
* handler
,
87 const ACE_Time_Value
& time
)
89 this->reactor_
->schedule_timer (handler
,
96 Monitor_Admin::reactor (ACE_Reactor
* new_reactor
)
98 this->reactor_
= new_reactor
;
99 this->default_reactor_
= false;
103 Monitor_Admin::reactor (void) const
105 return this->reactor_
;
110 ACE_END_VERSIONED_NAMESPACE_DECL
112 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */