1 #include "ClientTask.h"
2 #include "tao/Exception.h"
3 #include "ace/SString.h"
5 ClientTask::ClientTask()
11 ClientTask::~ClientTask()
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
);
24 ClientTask::num_loops(unsigned num_loops
)
26 this->num_loops_
= num_loops
;
30 ClientTask::open(void*)
32 size_t const num_threads
= this->engines_
.size();
36 ACE_ERROR_RETURN((LM_ERROR
,
37 "(%P|%t) ClientTask cannot activate 0 threads.\n"),
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
),
58 ClientEngine_Handle engine
;
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_
;
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_
;
87 "(%P|%t) ClientTask::svc caught unknown (...) exception "\
89 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
, ace_mon
, this->lock_
, 0);
90 ++this->failure_count_
;
98 ClientTask::close(u_long
)
105 ClientTask::failure_count() const
107 return this->failure_count_
;