Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / examples / CSD_Strategy / ThreadPool4 / Foo_i.cpp
blob453918983b5c868387b449ef305c76f6d10203e4
1 #include "Foo_i.h"
2 #include "OrbShutdownTask.h"
4 Foo_i::Foo_i(const char* servant_name)
5 : value_(0),
6 count_op1_(0),
7 count_op2_(0),
8 count_op3_(0),
9 count_op4_(0),
10 count_op5_(0),
11 servant_name_(servant_name)
16 Foo_i::~Foo_i()
21 void
22 Foo_i::op1()
24 ++this->count_op1_;
25 // Sleep for 10 milliseconds (10,000 microseconds)
26 //ACE_OS::sleep(ACE_Time_Value(0,10000));
30 void
31 Foo_i::op2(CORBA::Long value)
33 ++this->count_op2_;
34 this->value_ = value;
38 CORBA::Long
39 Foo_i::op3()
41 ++this->count_op3_;
42 return this->value_;
46 void
47 Foo_i::op4(CORBA::Long value)
49 ++this->count_op4_;
50 this->value_ = value;
52 if (this->count_op4_ % 1 == 0)
54 ACE_DEBUG((LM_DEBUG,
55 "(%P|%t) op4() has been called %d times now. value == %d\n",
56 this->count_op4_, this->value_));
59 // Sleep for 10 milliseconds (10,000 microseconds)
60 //ACE_OS::sleep(ACE_Time_Value(0,10000));
64 void
65 Foo_i::op5()
67 ACE_DEBUG((LM_DEBUG, "(%P|%t) Foo_i::op5() - ENTER\n"));
68 ACE_DEBUG((LM_DEBUG, "(%P|%t) Foo_i::op5() - Increment counter.\n"));
69 unsigned newcount = ++this->count_op5_;
70 ACE_DEBUG((LM_DEBUG, "(%P|%t) Foo_i::op5() - Counter is now %d.\n", newcount));
71 ACE_DEBUG((LM_DEBUG, "(%P|%t) Foo_i::op5() - EXIT - Raise a FooException.\n"));
75 CORBA::Boolean
76 Foo_i::op6 (
77 const char * user_name,
78 char *& message
81 ACE_CString str(message);
82 str += user_name;
83 CORBA::string_free (message);
84 message = CORBA::string_dup (str.c_str ());
85 return 1;
89 void
90 Foo_i::test_unbounded_string_arg (
91 const char * message
94 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_unbounded_string_arg ")
95 ACE_TEXT("got unbounded string %s\n"),
96 message));
100 void
101 Foo_i::test_bounded_string_arg (
102 const char * message
105 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_bounded_string_arg ")
106 ACE_TEXT("got bounded string %s\n"),
107 message));
111 void
112 Foo_i::test_fixed_array_arg (
113 const ::Fixed_Array message
116 for (CORBA::ULong i = 0; i < 20; i++)
118 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_array_arg ")
119 ACE_TEXT("got fixed_array[i] = %d\n"),
120 i, message[i]));
125 void
126 Foo_i::test_bounded_var_size_arg (
127 const ::Bounded_Var_Size & message
130 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_bounded_var_size_arg ")
131 ACE_TEXT("got var array chars %s\n"),
132 message.get_buffer ()));
136 void
137 Foo_i::test_unbounded_var_size_arg (
138 const ::Unbounded_Var_Size & message
141 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_unbounded_var_size_arg ")
142 ACE_TEXT("got var array chars %s\n"),
143 message.get_buffer ()));
147 void
148 Foo_i::test_fixed_size_arg (
149 const ::TimeOfDay & t
152 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_size_arg ")
153 ACE_TEXT("got timeofday %d:%d:%d\n"),
154 t.hour, t.minute, t.second));
157 void
158 Foo_i::test_fixed_size_arg_two_way (
159 const ::TimeOfDay & t
162 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_size_arg_two_way ")
163 ACE_TEXT("got timeofday %d:%d:%d\n"),
164 t.hour, t.minute, t.second));
167 void
168 Foo_i::test_var_array_arg (
169 const ::Var_Array messages
172 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
173 ACE_TEXT(" %s\n"), messages[0].in ()));
174 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
175 ACE_TEXT(" %s\n"), messages[1].in ()));
176 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
177 ACE_TEXT(" %s\n"), messages[2].in ()));
181 void
182 Foo_i::test_special_basic_arg (
183 ::CORBA::Boolean value
186 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_special_basic_arg ")
187 ACE_TEXT(" got special basic arg: %d\n"), value));
191 void
192 Foo_i::test_objref_arg (
193 ::Callback_ptr cb
196 this->callback_ = Callback::_duplicate (cb);
197 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_objref_arg ")
198 ACE_TEXT(" got callback object.\n")));
202 void
203 Foo_i::callback_object (
204 ::Callback_ptr cb
207 this->callback_ = Callback::_duplicate (cb);
210 void
211 Foo_i::test_callback (
214 if (CORBA::is_nil (this->callback_.in ()))
216 throw FooException ();
218 else
220 this->callback_->test_method ();
225 void
226 Foo_i::done()
228 static ACE_Atomic_Op <TAO_SYNCH_MUTEX, unsigned> num_clients = 2;
230 num_clients --;
232 if (num_clients == 0)
234 if (TheOrbShutdownTask::instance()->open(0) != 0)
236 ACE_ERROR((LM_ERROR, "(%P|%t)Foo_i::done: "
237 "failed to create orb shutdown thread.\n"));