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

« back to all changes in this revision

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