Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / Collocation_Exception_Test / Collocated_Test.cpp
blob29625fa56fa8203891141d3da44adf5196197530
1 #include "Server_Task.h"
2 #include "Client_Task.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/Argv_Type_Converter.h"
5 #include "ace/SString.h"
6 #include "ace/Manual_Event.h"
8 const ACE_TCHAR *output = ACE_TEXT("test.ior");
9 const ACE_TCHAR *input = ACE_TEXT("file://test.ior");
10 const char *mode = "SYNC_NONE";
12 // static int named_orbs = 0;
13 ACE_CString server_orb;
14 ACE_CString client_orb;
15 int
16 parse_args (int argc, ACE_TCHAR *argv[])
18 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:o:n:"));
19 int c;
21 while ((c = get_opts ()) != -1)
22 switch (c)
24 case 'o':
25 output = get_opts.opt_arg ();
26 break;
27 case 'k':
28 input = get_opts.opt_arg ();
29 break;
30 case 'n':
31 // named_orbs = 1;
32 server_orb.set ("server_orb");
33 client_orb.set ("client_orb");
34 break;
35 case '?':
36 default:
37 // This is a hack but that is okay!
38 return 0;
40 // Indicates successful parsing of the command line
41 return 0;
44 int
45 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
47 if (parse_args (argc,
48 argv) == -1)
49 return -1;
51 try
53 ACE_Argv_Type_Converter satc (argc, argv);
54 CORBA::ORB_var sorb =
55 CORBA::ORB_init (satc.get_argc (),
56 satc.get_TCHAR_argv (),
57 server_orb.c_str ());
59 ACE_Manual_Event me;
60 Server_Task server_task (output,
61 sorb.in (),
62 me,
63 ACE_Thread_Manager::instance ());
65 if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
67 1) == -1)
69 ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
72 // Wait for the server thread to do some processing
73 me.wait ();
75 ACE_Argv_Type_Converter catc (argc, argv);
76 CORBA::ORB_var corb =
77 CORBA::ORB_init (catc.get_argc (),
78 catc.get_TCHAR_argv (),
79 client_orb.c_str ());
81 Client_Task client_task (input,
82 corb.in (),
83 ACE_Thread_Manager::instance ());
85 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
87 1) == -1)
89 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
92 ACE_Thread_Manager::instance ()->wait ();
94 catch (const CORBA::Exception&)
96 // Ignore exceptions..
98 return 0;