Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Parallel_Connect_Strategy / client.cpp
blob0364c520ba5582dc8ca12a2a192f30848f9d422a
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/High_Res_Timer.h"
4 #include "tao/ORB_Core.h"
6 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
7 int kill_server = 0;
8 bool sanity_timeout = false;
10 void hook (TAO_ORB_Core *,
11 TAO_Stub *,
12 bool &has_timeout,
13 ACE_Time_Value &tv)
15 ACE_DEBUG ((LM_DEBUG, "Timeout hook called\n"));
16 tv.set (10, 0);
17 has_timeout = true;
20 int
21 parse_args (int argc, ACE_TCHAR *argv[])
23 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:xt"));
24 int c;
26 while ((c = get_opts ()) != -1)
27 switch (c)
29 case 'k':
30 ior = get_opts.opt_arg ();
31 break;
32 case 'x':
33 kill_server = 1;
34 break;
35 case 't':
36 sanity_timeout = true;
37 break;
38 case '?':
39 default:
40 ACE_ERROR_RETURN ((LM_ERROR,
41 "usage: %s "
42 "-k <ior> "
43 "-x "
44 "\n",
45 argv [0]),
46 -1);
48 // Indicates successful parsing of the command line
49 return 0;
52 int
53 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
55 try
57 CORBA::ORB_var orb =
58 CORBA::ORB_init (argc, argv);
60 if (parse_args (argc, argv) != 0)
61 return 1;
63 if (sanity_timeout)
65 ACE_DEBUG ((LM_DEBUG, "Installing sanity timeout\n"));
66 orb->orb_core ()->connection_timeout_hook (hook);
69 CORBA::Object_var tmp =
70 orb->string_to_object(ior);
72 ACE_High_Res_Timer hrt;
73 ACE_hrtime_t elapsed;
75 ACE_DEBUG ((LM_DEBUG,"Narrowing IOR - "));
76 hrt.start();
78 Test::Hello_var hello =
79 Test::Hello::_narrow(tmp.in ());
80 hrt.stop();
81 hrt.elapsed_microseconds (elapsed);
82 hrt.reset();
84 ACE_DEBUG ((LM_DEBUG,
85 ACE_TEXT("call completed in %d usec\n"),
86 elapsed ));
88 if (CORBA::is_nil (hello.in ()))
90 ACE_ERROR_RETURN ((LM_DEBUG,
91 "Nil Test::Hello reference <%s>\n",
92 ior),
93 1);
95 if (kill_server)
97 hello->shutdown ();
99 else
101 ACE_DEBUG ((LM_DEBUG,"Starting invocation 1 - "));
102 hrt.start();
103 CORBA::String_var the_string =
104 hello->get_string ();
105 hrt.stop();
106 hrt.elapsed_microseconds (elapsed);
107 ACE_DEBUG ((LM_DEBUG,
108 ACE_TEXT("call completed in %d usec\n"),
109 elapsed ));
110 ACE_DEBUG ((LM_DEBUG,"Starting invocation 2 - "));
111 hrt.reset();
112 hrt.start();
113 the_string = hello->get_string ();
114 hrt.stop();
115 hrt.elapsed_microseconds (elapsed);
116 ACE_DEBUG ((LM_DEBUG,
117 ACE_TEXT("call completed in %d usec\n"),
118 elapsed ));
120 orb->destroy ();
122 catch (const CORBA::Exception& ex)
124 ex._tao_print_exception ("Exception caught:");
125 return 1;
128 return 0;