1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
#include "Foo_i.h"
#include "OrbShutdownTask.h"
Foo_i::Foo_i(const char* servant_name)
: value_(0),
count_op1_(0),
count_op2_(0),
count_op3_(0),
count_op4_(0),
count_op5_(0),
servant_name_(servant_name)
{
}
Foo_i::~Foo_i()
{
}
void
Foo_i::op1(void)
{
++this->count_op1_;
// Sleep for 10 milliseconds (10,000 microseconds)
//ACE_OS::sleep(ACE_Time_Value(0,10000));
}
void
Foo_i::op2(CORBA::Long value)
{
++this->count_op2_;
this->value_ = value;
}
CORBA::Long
Foo_i::op3(void)
{
++this->count_op3_;
return this->value_;
}
void
Foo_i::op4(CORBA::Long value)
{
++this->count_op4_;
this->value_ = value;
if (this->count_op4_ % 1 == 0)
{
ACE_DEBUG((LM_DEBUG,
"(%P|%t) op4() has been called %d times now. value == %d\n",
this->count_op4_, this->value_));
}
// Sleep for 10 milliseconds (10,000 microseconds)
//ACE_OS::sleep(ACE_Time_Value(0,10000));
}
void
Foo_i::op5(void)
{
ACE_DEBUG((LM_DEBUG, "(%P|%t) Foo_i::op5() - ENTER\n"));
ACE_DEBUG((LM_DEBUG, "(%P|%t) Foo_i::op5() - Increment counter.\n"));
unsigned newcount = ++this->count_op5_;
ACE_DEBUG((LM_DEBUG, "(%P|%t) Foo_i::op5() - Counter is now %d.\n", newcount));
ACE_DEBUG((LM_DEBUG, "(%P|%t) Foo_i::op5() - EXIT - Raise a FooException.\n"));;
}
CORBA::Boolean
Foo_i::op6 (
const char * user_name,
char *& message
)
{
ACE_CString str(message);
str += user_name;
CORBA::string_free (message);
message = CORBA::string_dup (str.c_str ());
return 1;
}
void
Foo_i::test_unbounded_string_arg (
const char * message
)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_unbounded_string_arg ")
ACE_TEXT("got unbounded string %s\n"),
message));
}
void
Foo_i::test_bounded_string_arg (
const char * message
)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_bounded_string_arg ")
ACE_TEXT("got bounded string %s\n"),
message));
}
void
Foo_i::test_fixed_array_arg (
const ::Fixed_Array message
)
{
for (CORBA::ULong i = 0; i < 20; i++)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_array_arg ")
ACE_TEXT("got fixed_array[i] = %d\n"),
i, message[i]));
}
}
void
Foo_i::test_bounded_var_size_arg (
const ::Bounded_Var_Size & message
)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_bounded_var_size_arg ")
ACE_TEXT("got var array chars %s\n"),
message.get_buffer ()));
}
void
Foo_i::test_unbounded_var_size_arg (
const ::Unbounded_Var_Size & message
)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_unbounded_var_size_arg ")
ACE_TEXT("got var array chars %s\n"),
message.get_buffer ()));
}
void
Foo_i::test_fixed_size_arg (
const ::TimeOfDay & t
)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_size_arg ")
ACE_TEXT("got timeofday %d:%d:%d\n"),
t.hour, t.minute, t.second));
}
void
Foo_i::test_fixed_size_arg_two_way (
const ::TimeOfDay & t
)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_fixed_size_arg_two_way ")
ACE_TEXT("got timeofday %d:%d:%d\n"),
t.hour, t.minute, t.second));
}
void
Foo_i::test_var_array_arg (
const ::Var_Array messages
)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
ACE_TEXT(" %s\n"), messages[0].in ()));
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
ACE_TEXT(" %s\n"), messages[1].in ()));
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_var_array_arg ")
ACE_TEXT(" %s\n"), messages[2].in ()));
}
void
Foo_i::test_special_basic_arg (
::CORBA::Boolean value
)
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_special_basic_arg ")
ACE_TEXT(" got special basic arg: %d\n"), value));
}
void
Foo_i::test_objref_arg (
::Callback_ptr cb
)
{
this->callback_ = Callback::_duplicate (cb);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_i::test_objref_arg ")
ACE_TEXT(" got callback object.\n")));
}
void
Foo_i::callback_object (
::Callback_ptr cb
)
{
this->callback_ = Callback::_duplicate (cb);
}
void
Foo_i::test_callback (
)
{
if (CORBA::is_nil (this->callback_.in ()))
{
throw FooException ();
}
else
{
this->callback_->test_method ();
}
}
void
Foo_i::done(void)
{
static ACE_Atomic_Op <TAO_SYNCH_MUTEX, unsigned> num_clients = 2;
num_clients --;
if (num_clients == 0)
{
if (TheOrbShutdownTask::instance()->open(0) != 0)
{
ACE_ERROR((LM_ERROR, "(%P|%t)Foo_i::done: "
"failed to create orb shutdown thread.\n"));
}
}
}
|