Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Stack_Recursion / client.cpp
blob8b5fd8d03896717d7484d6caedfe6902d9731923
1 #include "Client_Task.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
5 static int iterations = 1000;
7 int
8 parse_args (int argc, ACE_TCHAR *argv[])
10 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("i:k:"));
11 int c;
13 while ((c = get_opts ()) != -1)
14 switch (c)
16 case 'i':
17 iterations = ACE_OS::atoi (get_opts.opt_arg ());
18 break;
19 case 'k':
20 ior = get_opts.opt_arg ();
21 break;
22 case '?':
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "usage: %s "
26 "-k <ior>"
27 "\n",
28 argv [0]),
29 -1);
31 // Indicates successful parsing of the command line
32 return 0;
35 int
36 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
38 try
40 CORBA::ORB_var orb =
41 CORBA::ORB_init (argc, argv);
43 if (parse_args (argc, argv) != 0)
44 return 1;
46 CORBA::Object_var tmp =
47 orb->string_to_object(ior);
49 Test::Sender_var sender =
50 Test::Sender::_narrow(tmp.in ());
52 if (CORBA::is_nil (sender.in ()))
54 ACE_ERROR_RETURN ((LM_DEBUG,
55 "Nil coordinator reference <%s>\n",
56 ior),
57 1);
61 Client_Task client_task (sender.in (),
62 iterations,
63 1048576,
64 ACE_Thread_Manager::instance ());
66 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 8, 1) == -1)
68 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
70 ACE_Thread_Manager::instance ()->wait ();
72 CORBA::Long count =
73 sender->get_event_count ();
75 ACE_DEBUG ((LM_DEBUG, "(%P) - Receiver got %d messages\n",
76 count));
78 // shutdown the remote ORB
79 sender->shutdown ();
83 orb->destroy ();
85 catch (const CORBA::Exception& ex)
87 ex._tao_print_exception ("Exception caught:");
88 return 1;
91 return 0;