Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / examples / CSD_Strategy / ThreadPool4 / ClientTask.cpp
blobfd06475dcffece7526c9bbc4b4f461f24a232362
1 //=============================================================================
2 /**
3 * @file ClientTask.cpp
5 * @author Tim Bradley <bradley_t@ociweb.com>
6 */
7 //=============================================================================
9 #include "ClientTask.h"
10 #include "ace/SString.h"
12 ClientTask::ClientTask(Foo_ptr foo,
13 Callback_ptr callback)
14 : foo_(Foo::_duplicate(foo)),
15 callback_(Callback::_duplicate(callback))
19 ClientTask::~ClientTask()
23 int
24 ClientTask::open(void*)
26 if (this->activate(THR_NEW_LWP | THR_JOINABLE, 1) != 0)
28 // Assumes that when activate returns non-zero return code that
29 // no threads were activated.
30 ACE_ERROR_RETURN((LM_ERROR,
31 "(%P|%t) ClientTask failed to activate "
32 "the client thread.\n"),
33 -1);
36 return 0;
40 int
41 ClientTask::svc()
43 ACE_DEBUG((LM_DEBUG,
44 "(%P|%t) ClientTask::svc start\n"));
46 try
48 for (CORBA::Long i = 1; i <= 100; i++)
50 // Simple Two-way calls.
51 this->foo_->op1();
53 this->foo_->op2(i);
54 CORBA::Long value = this->foo_->op3();
56 ACE_DEBUG((LM_DEBUG,
57 "(%P|%t) ===> Value retrieved from op3() == %d\n",
58 value));
60 for (CORBA::Long j = 1; j <= 5; j++)
62 this->foo_->op4(495 + (i * 5) + j);
65 try
67 ACE_DEBUG((LM_DEBUG, "(%P|%t) ===> Invoke op5()\n"));
68 this->foo_->op5();
69 ACE_DEBUG((LM_DEBUG, "(%P|%t) ===> No exception raised from op5(). :-(\n"));
71 catch (const FooException& )
73 ACE_DEBUG((LM_DEBUG,
74 "(%P|%t) ===> Caught FooException - as expected.\n"));
77 // Two-Way calls with inout parameters.
78 CORBA::String_var message = CORBA::string_dup( "Hello! " );
79 CORBA::Boolean result
80 = this->foo_->op6( "TAO User", message.inout());
82 if (result)
84 ACE_DEBUG((LM_DEBUG,
85 "(%P|%t) ===> Message from op6() == %s\n",
86 message.in ()));
88 else
90 ACE_DEBUG((LM_DEBUG,
91 "(%P|%t) ===> op6() returned false.\n"));
94 // Callback test.
95 this->foo_->callback_object (this->callback_.in ());
97 this->foo_->test_callback ();
99 // One-Way calls with various arguments.
100 CORBA::String_var ub_string = CORBA::string_dup( "UNBOUNDED STRING" );
101 this->foo_->test_unbounded_string_arg (ub_string.in ());
103 CORBA::String_var bd_string = CORBA::string_dup( "BOUNDED STRING" );
104 this->foo_->test_bounded_string_arg (bd_string.in ());
106 Fixed_Array fixed_array;
108 for (CORBA::ULong m = 0; m < 20; m ++)
110 fixed_array[m] = i + m;
113 this->foo_->test_fixed_array_arg (fixed_array);
115 Var_Array var_array;
116 var_array[0] = CORBA::string_dup( "STRING 1" );
117 var_array[1] = CORBA::string_dup( "STRING 2" );
118 var_array[2] = CORBA::string_dup( "STRING 3" );
119 this->foo_->test_var_array_arg (var_array);
121 Bounded_Var_Size_var bd_var_size_string = new Bounded_Var_Size();
122 char * buffer1 = CORBA::string_dup ("BOUNDED VAR SIZE CHAR");
123 bd_var_size_string->replace (ACE_OS::strlen (buffer1) + 1,
124 buffer1, true);
125 this->foo_->test_bounded_var_size_arg (bd_var_size_string.in ());
127 char * buffer2 = CORBA::string_dup ("UNBOUNDED VAR SIZE CHAR");
128 Unbounded_Var_Size_var ub_var_size_string = new Unbounded_Var_Size(100);
129 ub_var_size_string->replace (ub_var_size_string->maximum (),
130 ACE_OS::strlen (buffer2) + 1,
131 buffer2,
132 true);
133 this->foo_->test_unbounded_var_size_arg (ub_var_size_string.in ());
135 TimeOfDay t;
136 t.hour = 12;
137 t.minute = 30;
138 t.second = 10;
139 this->foo_->test_fixed_size_arg (t);
141 this->foo_->test_fixed_size_arg_two_way (t);
143 CORBA::Boolean special_value = 1;
144 this->foo_->test_special_basic_arg (special_value);
146 this->foo_->test_objref_arg (this->callback_.in ());
149 ACE_DEBUG((LM_DEBUG,
150 "(%P|%t) ClientTask::svc - Invoke foo->done()\n"));
152 this->foo_->done ();
153 ACE_DEBUG((LM_DEBUG,
154 "(%P|%t) ClientTask::svc - Back from foo->done()\n"));
156 catch (const CORBA::Exception& ex)
158 ex._tao_print_exception ("Caught exception in ClientTask::svc():");
160 catch (...)
162 ACE_ERROR((LM_ERROR,
163 "(%P|%t) Unknown (...) exception caught in ClientTask::svc()\n"));
167 ACE_DEBUG((LM_DEBUG,
168 "(%P|%t) ClientTask::svc end\n"));
170 return 0;
175 ClientTask::close(u_long)
177 ACE_DEBUG((LM_DEBUG,
178 "(%P|%t) ClientTask::close() - enter/exit\n"));
179 return 0;