Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / examples / CSD_Strategy / ThreadPool / Foo_i.cpp
blobddcf4f4e82f565b8da1760747686238a99b0fbd6
1 #include "Foo_i.h"
2 #include "OrbShutdownTask.h"
4 Foo_i::Foo_i(unsigned num_clients)
5 : value_(0),
6 num_clients_(num_clients),
7 count_op1_(0),
8 count_op2_(0),
9 count_op3_(0),
10 count_op4_(0),
11 count_op5_(0)
13 ACE_DEBUG((LM_DEBUG,
14 "(%P|%t) Number of clients for Foo_i servant: %d\n",
15 num_clients));
19 Foo_i::~Foo_i()
24 void
25 Foo_i::op1(void)
27 ++this->count_op1_;
28 // Sleep for 10 milliseconds (10,000 microseconds)
29 //ACE_OS::sleep(ACE_Time_Value(0,10000));
33 void
34 Foo_i::op2(CORBA::Long value)
36 ++this->count_op2_;
37 this->value_ = value;
41 CORBA::Long
42 Foo_i::op3(void)
44 ++this->count_op3_;
45 return this->value_;
49 void
50 Foo_i::op4(CORBA::Long value)
52 ++this->count_op4_;
53 this->value_ = value;
55 if (this->count_op4_ % 500 == 0)
57 ACE_DEBUG((LM_DEBUG,
58 "(%P|%t) op4() has been called %d times now. value == %d\n",
59 this->count_op4_, this->value_));
62 // Sleep for 10 milliseconds (10,000 microseconds)
63 //ACE_OS::sleep(ACE_Time_Value(0,10000));
67 void
68 Foo_i::op5(void)
70 ++this->count_op5_;;
74 void
75 Foo_i::done(void)
77 unsigned num_left = --this->num_clients_;
79 ACE_DEBUG((LM_DEBUG,
80 "(%P|%t) A client has reported that it is done(). "
81 "There are %d clients left.\n", num_left));
83 if (num_left == 0)
85 ACE_DEBUG((LM_DEBUG, "(%P|%t) Stats:\n"
86 "op1() count: %d\n"
87 "op2() count: %d\n"
88 "op3() count: %d\n"
89 "op4() count: %d\n"
90 "op5() count: %d\n",
91 this->count_op1_,
92 this->count_op2_,
93 this->count_op3_,
94 this->count_op4_,
95 this->count_op5_));
97 if (TheOrbShutdownTask::instance()->open(0) != 0)
99 ACE_ERROR((LM_ERROR, "(%P|%t)Foo_i::done: failed to create orb "\
100 "shutdown thread.\n"));