Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / examples / CSD_Strategy / ThreadPool5 / Foo_i.cpp
blob7a5925b63b9ed79a79aa2cde19526eaaabb63704
1 #include "Foo_i.h"
2 #include "FooServantList.h"
4 Foo_i::Foo_i(const char* servant_name,FooServantList* mgr)
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),
12 mgr_(mgr),
13 active_ (true)
18 Foo_i::~Foo_i()
23 void
24 Foo_i::op1(void)
26 ++this->count_op1_;
27 // Sleep for 10 milliseconds (10,000 microseconds)
28 //ACE_OS::sleep(ACE_Time_Value(0,10000));
32 void
33 Foo_i::op2(CORBA::Long value)
35 ++this->count_op2_;
36 this->value_ = value;
40 CORBA::Long
41 Foo_i::op3(void)
43 ++this->count_op3_;
45 if (this->count_op3_ == 30)
47 this->mgr_->deactivate_servant ();
50 return this->value_.value ();
54 void
55 Foo_i::op4(CORBA::Long value)
57 ++this->count_op4_;
58 this->value_ = value;
60 if (this->count_op4_.value () % 1 == 0)
62 ACE_DEBUG((LM_DEBUG,
63 "(%P|%t) op4() has been called %d times now. value == %d\n",
64 this->count_op4_.value (), this->value_.value ()));
67 // Sleep for 10 milliseconds (10,000 microseconds)
68 //ACE_OS::sleep(ACE_Time_Value(0,10000));
72 void
73 Foo_i::op5(void)
75 ++this->count_op5_;
76 throw FooException();
80 CORBA::Boolean
81 Foo_i::op6 (
82 const char * user_name,
83 char *& message
86 ACE_CString str(message);
87 str += user_name;
88 CORBA::string_free (message);
89 message = CORBA::string_dup (str.c_str ());
90 return 1;
94 void
95 Foo_i::test_unbounded_string_arg (
96 const char * message
99 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_unbounded_string_arg ")
100 ACE_TEXT("got unbounded string %s\n"),
101 message));
105 void
106 Foo_i::test_bounded_string_arg (
107 const char * message
110 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_bounded_string_arg ")
111 ACE_TEXT("got bounded string %s\n"),
112 message));
116 void
117 Foo_i::test_fixed_array_arg (
118 const ::Fixed_Array message
121 for (CORBA::ULong i = 0; i < 20; i++)
123 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_array_arg ")
124 ACE_TEXT("got fixed_array[i] = %d\n"),
125 i, message[i]));
130 void
131 Foo_i::test_bounded_var_size_arg (
132 const ::Bounded_Var_Size & message
135 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_bounded_var_size_arg ")
136 ACE_TEXT("got var array chars %s\n"),
137 message.get_buffer ()));
141 void
142 Foo_i::test_unbounded_var_size_arg (
143 const ::Unbounded_Var_Size & message
146 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_unbounded_var_size_arg ")
147 ACE_TEXT("got var array chars %s\n"),
148 message.get_buffer ()));
152 void
153 Foo_i::test_fixed_size_arg (
154 const ::TimeOfDay & t
157 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_size_arg ")
158 ACE_TEXT("got timeofday %d:%d:%d\n"),
159 t.hour, t.minute, t.second));
162 void
163 Foo_i::test_fixed_size_arg_two_way (
164 const ::TimeOfDay & t
167 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_size_arg_two_way ")
168 ACE_TEXT("got timeofday %d:%d:%d\n"),
169 t.hour, t.minute, t.second));
172 void
173 Foo_i::test_var_array_arg (
174 const ::Var_Array messages
177 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
178 ACE_TEXT(" %s\n"), messages[0].in ()));
179 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
180 ACE_TEXT(" %s\n"), messages[1].in ()));
181 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
182 ACE_TEXT(" %s\n"), messages[2].in ()));
186 void
187 Foo_i::test_special_basic_arg (
188 ::CORBA::Boolean value
191 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_special_basic_arg ")
192 ACE_TEXT(" got special basic arg: %d\n"), value));
196 void
197 Foo_i::test_objref_arg (
198 ::Callback_ptr cb
201 this->callback_ = Callback::_duplicate (cb);
202 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_objref_arg ")
203 ACE_TEXT(" got callback object.\n")));
207 void
208 Foo_i::callback_object (
209 ::Callback_ptr cb
212 this->callback_ = Callback::_duplicate (cb);
215 void
216 Foo_i::test_callback (
219 if (CORBA::is_nil (this->callback_.in ()))
221 throw FooException ();
223 else
225 this->callback_->test_method ();
230 void
231 Foo_i::done(void)
233 this->mgr_->client_done();
237 void
238 Foo_i::active (bool flag)
240 active_ = flag;
244 bool
245 Foo_i::active ()
247 return active_.value ();