1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
//**************************************************************************
//
// NAME : client.C
// DESCRIPTION:
//
// Client for the Cubit example
//
//****************************************************************************
#include "ace/Task.h"
#include "ace/Thread_Manager.h"
#include "ace/Get_Opt.h"
#include "api/api.H"
#include "cubit.H"
#include "Task_Client.h"
int LOOP_COUNT;
char SERVER_HOST [1024];
unsigned int THREAD_COUNT=1;
// = TITLE
// Parses the command line arguments and returns an error status
//
// = DESCRIPTION
// This method parses the command line arguments
int parse_args(int argc, char *argv[])
{
ACE_OS::strcpy (SERVER_HOST, "localhost");
ACE_Get_Opt opts (argc, argv, "dh:n:O:xt:");
int c;
while ((c = opts ()) != -1)
switch (c) {
case 'h':
ACE_OS::strcpy (SERVER_HOST, opts.optarg);
continue;
case 'd': // debug flag
continue;
case 'n': // loop count
LOOP_COUNT = (unsigned) ACE_OS::atoi (opts.optarg);
continue;
case 'O': // stringified objref
continue;
case 'x':
continue;
case 't':
THREAD_COUNT = (unsigned) ACE_OS::atoi (opts.optarg);
continue;
case '?':
default:
ACE_OS::fprintf (stderr, "usage: %s"
" [-d]"
" [-n loopcount]"
" [-h SERVER_HOST]"
" [-x]"
" [-t num_threads]"
"\n", argv [0]
);
return 1;
}
return 0; // Indicates successful parsing of command line
}
//
// Mainline
//
int
main (int argc, char *argv[])
{
if (parse_args (argc, argv) != 0)
return -1;
CORBA_Environment env;
CORBA_ORB_ptr orb = CORBA_ORB_init (argc, argv, 0, env);
if (env.exception ()) {
ACE_ERROR ((LM_ERROR, "ORB_init failed..\n"));
return -1;
}
COOL_NamingService_var naming = thisCapsule->naming_service (env);
CORBA_Object_ptr obj = new CORBA_Object;
naming->import ("Cubit", obj, env);
if (env.exception ()) {
ACE_ERROR ((LM_ERROR, "naming->import failed..\n"));
return -1;
}
Client clients (SERVER_HOST, THREAD_COUNT, LOOP_COUNT);
ACE_Thread_Manager::instance ()->wait ();
ACE_OS::printf ("Test done.\n"
"High priority client latency : %f msec\n"
"Low priority client latency : %f msec\n",
clients.get_high_priority_latency (),
clients.get_low_priority_latency ());
}
|