1
// server.cpp,v 1.5 2003/11/02 23:27:22 dhinton Exp
4
#include "Worker_Thread.h"
5
#include "ace/Get_Opt.h"
6
#include "ace/Sched_Params.h"
7
#include "ace/OS_NS_errno.h"
9
#include "tao/Strategies/advanced_resource.h"
11
ACE_RCSID(Thread_Pool_Latency, server, "server.cpp,v 1.5 2003/11/02 23:27:22 dhinton Exp")
13
const char *ior_output_file = "test.ior";
16
parse_args (int argc, char *argv[])
18
ACE_Get_Opt get_opts (argc, argv, "o:");
21
while ((c = get_opts ()) != -1)
25
ior_output_file = get_opts.opt_arg ();
30
ACE_ERROR_RETURN ((LM_ERROR,
37
// Indicates sucessful parsing of the command line
42
main (int argc, char *argv[])
45
(ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
46
+ ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
47
priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
49
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
51
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
53
ACE_SCOPE_PROCESS)) != 0)
55
if (ACE_OS::last_error () == EPERM)
58
"server (%P|%t): user is not superuser, "
59
"test runs in time-shared class\n"));
63
"server (%P|%t): sched_params failed\n"));
69
CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER);
72
CORBA::Object_var poa_object =
73
orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER);
76
if (CORBA::is_nil (poa_object.in ()))
77
ACE_ERROR_RETURN ((LM_ERROR,
78
" (%P|%t) Unable to initialize the POA.\n"),
81
PortableServer::POA_var root_poa =
82
PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER);
85
PortableServer::POAManager_var poa_manager =
86
root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
89
if (parse_args (argc, argv) != 0)
92
Roundtrip *roundtrip_impl;
93
ACE_NEW_RETURN (roundtrip_impl,
94
Roundtrip (orb.in ()),
96
PortableServer::ServantBase_var owner_transfer(roundtrip_impl);
98
Test::Roundtrip_var roundtrip =
99
roundtrip_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
102
CORBA::String_var ior =
103
orb->object_to_string (roundtrip.in () ACE_ENV_ARG_PARAMETER);
106
// If the ior_output_file exists, output the ior to it
107
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
108
if (output_file == 0)
109
ACE_ERROR_RETURN ((LM_ERROR,
110
"Cannot open output file for writing IOR: %s",
113
ACE_OS::fprintf (output_file, "%s", ior.in ());
114
ACE_OS::fclose (output_file);
116
poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
119
Worker_Thread worker (orb.in ());
121
worker.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1);
122
worker.thr_mgr ()->wait ();
124
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
126
root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
129
orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
134
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught:");