Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / performance-tests / CSD_Strategy / TestInf / ClientTask.cpp
blobebe2b95e756fc466eca8d76580c1f7519c7a0faa
1 #include "ClientTask.h"
2 #include "tao/Exception.h"
3 #include "ace/SString.h"
5 ClientTask::ClientTask()
6 : failure_count_(0),
7 num_loops_(1)
11 ClientTask::~ClientTask()
15 void
16 ClientTask::add_engine(ClientEngine* engine)
18 // Pass in false so that _add_ref() is called.
19 ClientEngine_Handle engine_handle(engine,false);
20 this->engines_.push_back(engine_handle);
23 void
24 ClientTask::num_loops(unsigned num_loops)
26 this->num_loops_ = num_loops;
29 int
30 ClientTask::open(void*)
32 size_t const num_threads = this->engines_.size();
34 if (num_threads == 0)
36 ACE_ERROR_RETURN((LM_ERROR,
37 "(%P|%t) ClientTask cannot activate 0 threads.\n"),
38 -1);
41 if (this->activate(THR_NEW_LWP | THR_JOINABLE, num_threads) != 0)
43 // Assumes that when activate returns non-zero return code that
44 // no threads were activated.
45 ACE_ERROR_RETURN((LM_ERROR,
46 "(%P|%t) ClientTask failed to activate "
47 "the %d client threads.\n", num_threads),
48 -1);
51 return 0;
55 int
56 ClientTask::svc()
58 ClientEngine_Handle engine;
59 unsigned num_loops;
62 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
63 this->engines_.get(engine, this->engines_.size() - 1);
64 this->engines_.pop_back();
65 num_loops = this->num_loops_;
68 try
70 if (engine->execute(num_loops) == false)
72 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
73 ++this->failure_count_;
76 catch (const CORBA::Exception& ex)
78 ex._tao_print_exception (
79 "ClientTask::svc Caught exception from execute():");
81 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
82 ++this->failure_count_ ;
84 catch (...)
86 ACE_ERROR((LM_ERROR,
87 "(%P|%t) ClientTask::svc caught unknown (...) exception "\
88 "in execute() " ));
89 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
90 ++this->failure_count_;
93 return 0;
97 int
98 ClientTask::close(u_long)
100 return 0;
104 unsigned
105 ClientTask::failure_count() const
107 return this->failure_count_;