blob: 5594914a6cb6377cd4c08c28608a2e0df88081f8 (
plain)
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
|
#include "OrbRunner.h"
#include "OrbTask.h"
#include "TestAppExceptionC.h"
OrbRunner::OrbRunner(CORBA::ORB_ptr orb, unsigned num_orb_threads)
: orb_(CORBA::ORB::_duplicate(orb)),
num_orb_threads_(num_orb_threads)
{
}
OrbRunner::~OrbRunner()
{
}
void
OrbRunner::run()
{
ACE_ASSERT(this->num_orb_threads_ > 0);
// If the num_orb_threads_ is exactly one, then just use the current
// (mainline) thread to run the ORB event loop.
if (this->num_orb_threads_ == 1)
{
// Since the num_orb_threads_ is exactly one, we just use the current
// (mainline) thread to run the ORB event loop.
this->orb_->run();
}
else
{
// The num_orb_threads_ is greater than 1, so we will use an OrbTask
// (active object) to run the ORB event loop in (num_orb_threads_ - 1)
// threads. We use the current (mainline) thread as the other thread
// running the ORB event loop.
OrbTask orb_task(this->orb_.in(), this->num_orb_threads_ - 1);
// Activate the OrbTask worker threads
if (orb_task.open(0) != 0)
{
ACE_ERROR((LM_ERROR,
"(%P|%t) Failed to open the OrbTask.\n"));
throw TestAppException();
}
// This will use the current (mainline) thread to run the ORB event loop.
this->orb_->run();
// Now that the current thread has unblocked from running the orb,
// make sure to wait for all of the worker threads to complete.
orb_task.wait();
}
}
|