summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp')
-rw-r--r--TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp88
1 files changed, 83 insertions, 5 deletions
diff --git a/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp
index 400c3ba1f53..c13f42e31ca 100644
--- a/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp
+++ b/TAO/CIAO/DAnCE/new_RepositoryManager/RepositoryManager.cpp
@@ -1,22 +1,58 @@
// $Id$
-//RepositoryManager.cpp, v2.0 Stoyan
+/***
+ * @file RepositoryManager.cpp
+ *
+ * @author Stoyan Paunov <spaunov@isis.vanderbilt.edu>
+ **/
+
#include "new_RepositoryManager_Impl.h"
#include "ace/OS_NS_stdio.h"
#include "ace/streams.h"
#include "ace/Auto_Ptr.h"
+#include "ace/Task.h"
using namespace std;
+namespace
+{
+///name of the file holding the IOR of the RM
const char * rm_ior = "RepositoryManagerDeamon.ior";
+///default number of worker threads to run in the multi-threaded RM
+const unsigned int nthreads = 3;
+}
-int
-ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+
+///Class that implements the service routine of the worker threads
+///of the repository manager
+
+class Worker : public ACE_Task_Base
{
+ // = TITLE
+ // Run a server thread
+ //
+ // = DESCRIPTION
+ // Use the ACE_Task_Base class to run server threads
+ //
+public:
+ Worker (CORBA::ORB_ptr orb);
+ // ctor
+
+ virtual int svc (void);
+ // The thread entry point.
- //check the previous implementation for stuff to reuse!
+private:
+ CORBA::ORB_var orb_;
+ // The orb
+};
+
+///Main function
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
try
{
//init the ORB
@@ -38,7 +74,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
//trasfer ownership to the POA
PortableServer::ServantBase_var distributor_owner_transfer(repo);
- //register servant
+ //register and implicitly activate servant
CIAO::new_RepositoryManagerDaemon_var RepositoryManagerDeamon = repo->_this ();
//convert the IOR to string
@@ -56,6 +92,20 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
ACE_OS::fprintf (ior_out, "%s", ior.in ());
ACE_OS::fclose (ior_out);
+ Worker worker (orb.in ());
+ if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
+ nthreads) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot activate client threads\n"),
+ 1);
+
+ worker.thr_mgr ()->wait ();
+
+ ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
+
+ //done
+ return 0;
+
//Start accepting requests
orb->run ();
@@ -77,3 +127,31 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
return 0;
}
+
+
+// ****************************************************************
+
+///Constuctor for the worker class
+Worker::Worker (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+///implementation of the service routine inherited from ACE::Task_Base
+
+int Worker::svc (void)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ }
+ ACE_ENDTRY;
+ return 0;
+}
+
+