Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / examples / CSD_Strategy / ThreadPool3 / OrbTask.cpp
blob5585508819075228b4ab00892d8eddc3621f2c12
1 //=============================================================================
2 /**
3 * @file OrbTask.cpp
5 * @author Tim Bradley <bradley_t@ociweb.com>
6 */
7 //=============================================================================
9 #include "OrbTask.h"
11 namespace { enum { MAX_ORB_TASK_WORKER_THREADS = 20 }; }
13 OrbTask::OrbTask(CORBA::ORB_ptr orb, unsigned num_threads)
14 : orb_ (CORBA::ORB::_duplicate(orb)),
15 num_threads_(num_threads)
19 int
20 OrbTask::open(void*)
22 if (this->num_threads_ < 1)
24 ACE_ERROR_RETURN((LM_ERROR,
25 "(%P|%t) OrbTask failed to open. "
26 "num_threads_ (%d) is less-than 1.\n",
27 this->num_threads_),
28 -1);
31 if (this->num_threads_ > MAX_ORB_TASK_WORKER_THREADS)
33 ACE_ERROR_RETURN((LM_ERROR,
34 "(%P|%t) OrbTask failed to open. "
35 "num_threads_ (%d) is too large. Max is %d.\n",
36 this->num_threads_, MAX_ORB_TASK_WORKER_THREADS),
37 -1);
40 if (CORBA::is_nil(this->orb_.in()))
42 ACE_ERROR_RETURN((LM_ERROR,
43 "(%P|%t) OrbTask failed to open. "
44 "ORB object reference is nil.\n"),
45 -1);
48 if (this->activate(THR_NEW_LWP | THR_JOINABLE, this->num_threads_) != 0)
50 // Assumes that when activate returns non-zero return code that
51 // no threads were activated.
52 ACE_ERROR_RETURN((LM_ERROR,
53 "(%P|%t) OrbTask failed to activate "
54 "(%d) worker threads.\n",
55 this->num_threads_),
56 -1);
59 return 0;
63 int
64 OrbTask::svc()
66 try
68 this->orb_->run();
70 catch (...)
72 ACE_ERROR((LM_ERROR,
73 "(%P|%t) Exception raised by ORB::run() method. "
74 "OrbTask is stopping.\n"));
77 return 0;
81 int
82 OrbTask::close(u_long)
84 return 0;