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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
//
// $Id$
//
#include "Test_i.h"
#include "ace/OS_NS_unistd.h"
Sleeper_i::Sleeper_i (CORBA::ORB_ptr orb)
: orb_ (CORBA::ORB::_duplicate (orb))
{
}
void
Sleeper_i::delay(CORBA::Short sec)
{
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Sleeper_i::delay called\n")));
ACE_OS::sleep (sec);
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Sleeper_i::delay returning\n")));
}
void
Sleeper_i::shutdown (void)
{
this->orb_->shutdown (0);
}
//-----------------------------------------------
Middle_i::Middle_i (CORBA::ORB_ptr orb, Test::Sleeper_ptr s)
: orb_ (CORBA::ORB::_duplicate (orb)),
sleeper_ (Test::Sleeper::_duplicate (s))
{
}
void
Middle_i::call_delay(CORBA::Short sec)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Middle_i::delay called\n")));
ACE_hthread_t thr;
ACE_Thread::self (thr);
bool recursive = false;
{
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_);
int result = this->threads_.insert (thr);
ACE_ASSERT (result != -1);
if (result == 1)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Middle_i::call_delay, ")
ACE_TEXT ("recursive upcall detected for thr = %d\n"),
thr));
recursive = true;
}
}
this->sleeper_->delay(sec);
if (!recursive)
{
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_);
int result = this->threads_.remove (thr);
if (result == -1)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Middle_i::call_delay, ")
ACE_TEXT ("unable to remove thr = %d\n"),
thr));
ACE_ASSERT (result != -1);
}
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT("(%P|%t) Middle_i::delay returning recursive = %d\n"),
recursive));
}
void
Middle_i::shutdown (void)
{
sleeper_->shutdown ();
this->orb_->shutdown (0);
}
|