~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to TAO/performance-tests/Latency/Thread_Pool/server.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// server.cpp,v 1.5 2003/11/02 23:27:22 dhinton Exp
2
 
 
3
 
#include "Roundtrip.h"
4
 
#include "Worker_Thread.h"
5
 
#include "ace/Get_Opt.h"
6
 
#include "ace/Sched_Params.h"
7
 
#include "ace/OS_NS_errno.h"
8
 
 
9
 
#include "tao/Strategies/advanced_resource.h"
10
 
 
11
 
ACE_RCSID(Thread_Pool_Latency, server, "server.cpp,v 1.5 2003/11/02 23:27:22 dhinton Exp")
12
 
 
13
 
const char *ior_output_file = "test.ior";
14
 
 
15
 
int
16
 
parse_args (int argc, char *argv[])
17
 
{
18
 
  ACE_Get_Opt get_opts (argc, argv, "o:");
19
 
  int c;
20
 
 
21
 
  while ((c = get_opts ()) != -1)
22
 
    switch (c)
23
 
      {
24
 
      case 'o':
25
 
        ior_output_file = get_opts.opt_arg ();
26
 
        break;
27
 
 
28
 
      case '?':
29
 
      default:
30
 
        ACE_ERROR_RETURN ((LM_ERROR,
31
 
                           "usage:  %s "
32
 
                           "-o <iorfile>"
33
 
                           "\n",
34
 
                           argv [0]),
35
 
                          -1);
36
 
      }
37
 
  // Indicates sucessful parsing of the command line
38
 
  return 0;
39
 
}
40
 
 
41
 
int
42
 
main (int argc, char *argv[])
43
 
{
44
 
  int priority =
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,
48
 
                                                  priority);
49
 
  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
50
 
 
51
 
  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
52
 
                                              priority,
53
 
                                              ACE_SCOPE_PROCESS)) != 0)
54
 
    {
55
 
      if (ACE_OS::last_error () == EPERM)
56
 
        {
57
 
          ACE_DEBUG ((LM_DEBUG,
58
 
                      "server (%P|%t): user is not superuser, "
59
 
                      "test runs in time-shared class\n"));
60
 
        }
61
 
      else
62
 
        ACE_ERROR ((LM_ERROR,
63
 
                    "server (%P|%t): sched_params failed\n"));
64
 
    }
65
 
 
66
 
  ACE_TRY_NEW_ENV
67
 
    {
68
 
      CORBA::ORB_var orb =
69
 
        CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER);
70
 
      ACE_TRY_CHECK;
71
 
 
72
 
      CORBA::Object_var poa_object =
73
 
        orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER);
74
 
      ACE_TRY_CHECK;
75
 
 
76
 
      if (CORBA::is_nil (poa_object.in ()))
77
 
        ACE_ERROR_RETURN ((LM_ERROR,
78
 
                           " (%P|%t) Unable to initialize the POA.\n"),
79
 
                          1);
80
 
 
81
 
      PortableServer::POA_var root_poa =
82
 
        PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER);
83
 
      ACE_TRY_CHECK;
84
 
 
85
 
      PortableServer::POAManager_var poa_manager =
86
 
        root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
87
 
      ACE_TRY_CHECK;
88
 
 
89
 
      if (parse_args (argc, argv) != 0)
90
 
        return 1;
91
 
 
92
 
      Roundtrip *roundtrip_impl;
93
 
      ACE_NEW_RETURN (roundtrip_impl,
94
 
                      Roundtrip (orb.in ()),
95
 
                      1);
96
 
      PortableServer::ServantBase_var owner_transfer(roundtrip_impl);
97
 
 
98
 
      Test::Roundtrip_var roundtrip =
99
 
        roundtrip_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
100
 
      ACE_TRY_CHECK;
101
 
 
102
 
      CORBA::String_var ior =
103
 
        orb->object_to_string (roundtrip.in () ACE_ENV_ARG_PARAMETER);
104
 
      ACE_TRY_CHECK;
105
 
 
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",
111
 
                           ior_output_file),
112
 
                          1);
113
 
      ACE_OS::fprintf (output_file, "%s", ior.in ());
114
 
      ACE_OS::fclose (output_file);
115
 
 
116
 
      poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
117
 
      ACE_TRY_CHECK;
118
 
 
119
 
      Worker_Thread worker (orb.in ());
120
 
 
121
 
      worker.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1);
122
 
      worker.thr_mgr ()->wait ();
123
 
 
124
 
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
125
 
 
126
 
      root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
127
 
      ACE_TRY_CHECK;
128
 
 
129
 
      orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
130
 
      ACE_TRY_CHECK;
131
 
    }
132
 
  ACE_CATCHANY
133
 
    {
134
 
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught:");
135
 
      return 1;
136
 
    }
137
 
  ACE_ENDTRY;
138
 
 
139
 
  return 0;
140
 
}