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

« back to all changes in this revision

Viewing changes to TAO/performance-tests/Cubit/TAO/IDL_Cubit/collocation_test.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
 
// collocation_test.cpp,v 1.24 2003/11/04 05:21:33 dhinton Exp
2
 
 
3
 
#include "Cubit_Client.h"
4
 
#include "Cubit_Server.h"
5
 
 
6
 
#include "tao/Strategies/advanced_resource.h"
7
 
 
8
 
#include "ace/Barrier.h"
9
 
#include "ace/Get_Opt.h"
10
 
#include "ace/ARGV.h"
11
 
#include "ace/Thread_Manager.h"
12
 
 
13
 
ACE_RCSID(IDL_Cubit, collocation_test, "collocation_test.cpp,v 1.24 2003/11/04 05:21:33 dhinton Exp")
14
 
 
15
 
#define  THE_IOR "theior"
16
 
 
17
 
struct Barriers
18
 
{
19
 
  Barriers (unsigned int init)
20
 
    : server_init_ (init),
21
 
      client_fini_ (init)
22
 
  {}
23
 
 
24
 
  ACE_Barrier server_init_;
25
 
  ACE_Barrier client_fini_;
26
 
};
27
 
 
28
 
static const char *server_cmd = 0;
29
 
 
30
 
void *
31
 
svr_worker (void *arg)
32
 
{
33
 
  Cubit_Server cubit_server;
34
 
  Barriers *barrier = (Barriers *) arg;
35
 
 
36
 
  char cmd_line[1024];
37
 
  ACE_OS::strcpy (cmd_line, "server ");
38
 
  if (server_cmd != 0)
39
 
    ACE_OS::strcat (cmd_line, server_cmd);
40
 
  ACE_OS::strcat (cmd_line, " -f " THE_IOR);
41
 
  ACE_ARGV args (cmd_line);
42
 
 
43
 
  ACE_TRY_NEW_ENV
44
 
    {
45
 
      int result = cubit_server.init (args.argc (),
46
 
                                      args.argv ()
47
 
                                      ACE_ENV_ARG_PARAMETER);
48
 
      ACE_TRY_CHECK;
49
 
 
50
 
      if (result == -1)
51
 
        return (void *) 1;
52
 
 
53
 
      barrier->server_init_.wait ();
54
 
      cubit_server.run (ACE_ENV_SINGLE_ARG_PARAMETER);
55
 
      ACE_TRY_CHECK;
56
 
 
57
 
      barrier->client_fini_.wait ();
58
 
    }
59
 
  ACE_CATCH (CORBA::SystemException, sysex)
60
 
    {
61
 
      ACE_PRINT_EXCEPTION (sysex, "System Exception");
62
 
      return (void *) 1;
63
 
    }
64
 
  ACE_CATCH (CORBA::UserException, userex)
65
 
    {
66
 
      ACE_PRINT_EXCEPTION (userex, "User Exception");
67
 
      return (void *) 1;
68
 
    }
69
 
  ACE_ENDTRY;
70
 
  return 0;
71
 
}
72
 
 
73
 
 
74
 
int
75
 
main (int argc, char **argv)
76
 
{
77
 
  ACE_Get_Opt get_opts (argc, argv, "s:c:");
78
 
  int c = -1;
79
 
  const char *client_cmd = 0;
80
 
 
81
 
  while ((c = get_opts ()) != -1)
82
 
    switch (c)
83
 
      {
84
 
      case 'c':
85
 
        client_cmd = get_opts.opt_arg ();
86
 
        ACE_DEBUG ((LM_DEBUG, "Client argument: %s\n", client_cmd));
87
 
        break;
88
 
      case 's':
89
 
        server_cmd = get_opts.opt_arg ();
90
 
        ACE_DEBUG ((LM_DEBUG, "Server argument: %s\n", server_cmd));
91
 
        break;
92
 
      default:
93
 
        ACE_ERROR_RETURN ((LM_ERROR,
94
 
                           "Usage: collocation_test -s \"server opts\" -c \"client opts\""),
95
 
                          -1);
96
 
      }
97
 
 
98
 
  char cmd_line[1024];
99
 
  ACE_OS::strcpy (cmd_line, "client ");
100
 
  if (client_cmd != 0)
101
 
    ACE_OS::strcat (cmd_line, client_cmd);
102
 
  ACE_OS::strcat (cmd_line, " -f " THE_IOR);
103
 
  ACE_ARGV args (cmd_line);
104
 
 
105
 
  Barriers barrier (2);
106
 
 
107
 
  int retv = 1;
108
 
 
109
 
  ACE_DEBUG ((LM_DEBUG,
110
 
              "\n \t IDL_Cubit: Collocation test \n\n"));
111
 
 
112
 
  ACE_Thread_Manager tm;
113
 
  tm.spawn (ACE_reinterpret_cast (ACE_THR_FUNC, &svr_worker),
114
 
            &barrier);
115
 
  barrier.server_init_.wait ();
116
 
  ACE_OS::sleep (1);
117
 
 
118
 
  Cubit_Client cubit_client (1);
119
 
  // Make sure the server shuts itself down afterward.
120
 
 
121
 
  if (cubit_client.init (args.argc (), args.argv ()) == -1)
122
 
    return 1;
123
 
  else
124
 
    retv = cubit_client.run ();
125
 
 
126
 
  barrier.client_fini_.wait ();
127
 
  tm.wait ();
128
 
 
129
 
  ACE_OS::unlink (THE_IOR);
130
 
  return retv;
131
 
}