summaryrefslogtreecommitdiff
path: root/TAO/tests/Dynamic_TP/ORB_ThreadPool/Server.cpp
diff options
context:
space:
mode:
authorstanleyk <stanleyk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2013-02-05 21:11:03 +0000
committerstanleyk <stanleyk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2013-02-05 21:11:03 +0000
commit5e030faf84086ab02059fcbcc3faed224bd57b95 (patch)
tree3a62df45ac6ccf599fb07cf6a03d672456ce2e3d /TAO/tests/Dynamic_TP/ORB_ThreadPool/Server.cpp
parent9d296f7fa51116ff7040ecb2ad18612cd94b5fd1 (diff)
downloadATCD-5e030faf84086ab02059fcbcc3faed224bd57b95.tar.gz
Merge in OCI_Reliability_Enhancements branch.
Diffstat (limited to 'TAO/tests/Dynamic_TP/ORB_ThreadPool/Server.cpp')
-rw-r--r--TAO/tests/Dynamic_TP/ORB_ThreadPool/Server.cpp111
1 files changed, 111 insertions, 0 deletions
diff --git a/TAO/tests/Dynamic_TP/ORB_ThreadPool/Server.cpp b/TAO/tests/Dynamic_TP/ORB_ThreadPool/Server.cpp
new file mode 100644
index 00000000000..fc23726e81c
--- /dev/null
+++ b/TAO/tests/Dynamic_TP/ORB_ThreadPool/Server.cpp
@@ -0,0 +1,111 @@
+// $Id$
+
+#include "Test_i.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/Thread_Manager.h"
+
+#include "tao/ORB_Core_TSS_Resources.h"
+#include "tao/ORB_Core.h"
+#include "tao/Dynamic_TP/DTP_Thread_Pool.h"
+
+const ACE_TCHAR *ior_output_file = ACE_TEXT ("server.ior");
+
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:s:p:"));
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates successful parsing of the command line
+ return 0;
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references("RootPOA");
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ if (CORBA::is_nil (root_poa.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Panic: nil RootPOA\n"),
+ 1);
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager ();
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ Test_i *test_impl;
+ ACE_NEW_RETURN (test_impl, Test_i (orb.in ()), 1);
+ PortableServer::ServantBase_var owner_transfer(test_impl);
+ PortableServer::ObjectId_var id = root_poa->activate_object (test_impl);
+ CORBA::Object_var object = root_poa->id_to_reference (id.in ());
+ Test::Sleeper_var sleeper = Test::Sleeper::_narrow (object.in ());
+ CORBA::String_var ior = orb->object_to_string (sleeper.in ());
+
+ ACE_DEBUG ((LM_DEBUG,"Server calling poa_manager::activate()\n"));
+ poa_manager->activate ();
+
+ // Output the IOR to the <ior_output_file>
+ FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open output file %s for writing IOR: %C",
+ ior_output_file,
+ ior.in ()),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ TAO_ORB_Core_TSS_Resources &tss =
+ *orb->orb_core ()->get_tss_resources ();
+
+ // The API calls it a lane but DTP Thread Pools
+ // are always a single lane.
+ TAO_DTP_Thread_Pool *pool =
+ static_cast <TAO_DTP_Thread_Pool *> (tss.lane_);
+
+#if 0
+ ACE_DEBUG ((LM_DEBUG,"Server calling orb::run()\n"));
+ orb->run ();
+#else
+ pool->wait();
+#endif
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return 0;
+}