summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp')
-rw-r--r--TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp101
1 files changed, 55 insertions, 46 deletions
diff --git a/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp b/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp
index 43ba6ed9975..59727210f16 100644
--- a/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp
+++ b/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp
@@ -20,25 +20,24 @@
#include "ace/DLL.h"
#include "ace/SString.h"
-#if !defined (__ACE_INLINE__)
-#include "MonitorController.inl"
-#endif /* !defined INLINE */
-
-typedef MonitorBase* (*MonitorFactory) (void);
+namespace CIAO
+{
+ typedef MonitorBase* (*MonitorFactory) (void);
-/// for the CIAO monitor
-const char* monitor_lib_name = "ciaomonlib";
+ /// for the CIAO monitor
+ const char* monitor_lib_name = "ciaomonlib";
-// The interval after which update will be sent.
-// This value will sent by the EM in the later implementation
-const int interval = 10;
+ // The interval after which update will be sent.
+ // This value will sent by the EM in the later implementation
+ const int interval = 10;
-static const char* factory_func = "createMonitor";
+ static const char* factory_func = "createMonitor";
+};
-MonitorController::MonitorController (CORBA::ORB_ptr orb,
- ::Deployment::Domain& domain,
- ::Deployment::TargetManager_ptr target
- )
+CIAO::MonitorController::MonitorController (CORBA::ORB_ptr orb,
+ ::Deployment::Domain& domain,
+ ::Deployment::TargetManager_ptr target
+ )
: target_facet_i_ (::Deployment::TargetManager::_duplicate (target)),
terminate_flag_ (0),
orb_ (orb),
@@ -46,11 +45,9 @@ MonitorController::MonitorController (CORBA::ORB_ptr orb,
{
}
-int MonitorController::init()
+int CIAO::MonitorController::svc (void)
{
- ACE_DEBUG ((LM_DEBUG , "Calling MonitorController Init\n"));
-
- ACE_DLL dll;
+ ACE_DLL dll;
// forming the library name
ACE_CString lib_name = ACE_DLL_PREFIX;
@@ -72,7 +69,7 @@ int MonitorController::init()
if (factory == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"%p",
- "dll.symbol"),
+ "dll.symbol"),
-1);
{
ACE_TRACE ((LM_DEBUG "Inside the init call\n"));
@@ -85,46 +82,58 @@ int MonitorController::init()
// Start the Monitor
monitor_->start (orb_);
- std::auto_ptr <MonitorCB> monitor_callback (
- new MonitorCB (orb_,
- target_facet_i_.in (),
- interval));
+ auto_ptr <CIAO::MonitorCB> monitor_callback (new CIAO::MonitorCB (orb_,
+ target_facet_i_.in (),
+ interval));
// The loop in which UpdateData is called
while (!terminating ())
- {
- // data will be updated in intervals of 10 secs.
- // in the latest version of spec , this value will
- // come from Execution Manager
- ACE_OS::sleep (interval);
-// ACE_DEBUG ((LM_DEBUG , "=The Terminate is %d\n", terminate_flag_));
- ::Deployment::Domain* domain =
- monitor_->get_current_data ();
-
- monitor_callback->update_data (*domain);
- }
+ {
+ // data will be updated in intervals of 10 secs.
+ // in the latest version of spec , this value will
+ // come from Execution Manager
+ ACE_OS::sleep (interval);
+ // ACE_DEBUG ((LM_DEBUG , "=The Terminate is %d\n", terminate_flag_));
+ ::Deployment::Domain* domain =
+ monitor_->get_current_data ();
+
+ monitor_callback->update_data (*domain);
+ }
monitor_->stop ();
}
dll.close ();
+ if (CIAO::debug_level () > 9)
+ {
+ ACE_DEBUG ((LM_DEBUG , "Terminating Monitor\n"));
+ }
return 0;
-
}
+CIAO::MonitorController::~MonitorController ()
+{
+ terminate ();
+ wait ();
+}
-int MonitorController::svc (void)
+void CIAO::MonitorController::terminate ()
{
- init ();
- if (CIAO::debug_level () > 9)
- {
- ACE_DEBUG ((LM_DEBUG , "Terminating Monitor\n"));
- }
- return 0;
+ // make the terminate flag false
+ ACE_GUARD (ACE_SYNCH_MUTEX,
+ guard,
+ lock_
+ );
+ ACE_DEBUG ((LM_DEBUG , "WITHIN TERMINATE CALL ......"));
+ terminate_flag_=1;
}
-MonitorController::~MonitorController ()
+bool CIAO::MonitorController::terminating ()
{
- terminate ();
- wait ();
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX,
+ guard,
+ lock_,
+ 0
+ );
+ return terminate_flag_;
}