summaryrefslogtreecommitdiff
path: root/TAO/tests/Cubit/COOL/client.cpp
blob: 3b3518c15a89a5ddcb6a58bda90b63b4a5ac05b6 (plain)
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
//**************************************************************************
//
// 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=100;
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, "n:t:");
  int			c;
  
  while ((c = opts ()) != -1)
    switch (c) {
    case 'h':
      ACE_OS::strcpy (SERVER_HOST, opts.optarg);
      continue;
    case 'n':			// loop count
      LOOP_COUNT = (unsigned) ACE_OS::atoi (opts.optarg);
      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 [])
{
  CORBA_Environment env;
  CORBA_ORB_ptr orb = CORBA_ORB_init (argc, argv, 0, env);

  if (parse_args (argc, argv) != 0)
    return -1;

  if (env.exception ()) {
    ACE_ERROR ((LM_ERROR, "ORB_init 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 ());

}