blob: 8416cdb76c7c0ef9a4a39cb67ccf07e32da590bf (
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
|
// $Id$
#include "Hello.h"
#include "ace/Task.h"
ACE_THR_FUNC_RETURN killer (void *arg)
{
CORBA::ORB_var orb = reinterpret_cast<CORBA::ORB_ptr> (arg);
ACE_DEBUG ((LM_DEBUG,"(%P|%t) server exiting\n"));
orb->shutdown (1);
return 0;
}
Hello::Hello (CORBA::ORB_ptr orb)
: orb_ (CORBA::ORB::_duplicate (orb)),
count_(0)
{
}
void
Hello::set_callback (Test::CallBack_ptr cb)
{
ACE_DEBUG ((LM_DEBUG,"(%P|%t) got callback\n"));
this->callback_ = Test::CallBack::_duplicate(cb);
this->callback_->method2();
}
void
Hello::method (CORBA::Short count)
{
if (++this->count_ > 10)
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t) supplied count = %d\n", count));
PortableServer::POA_var poa = this->_default_POA();
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->hold_requests(false);
// Pass duplicated ptr to a thread and let the thread to free the reference.
CORBA::ORB_ptr orb = CORBA::ORB::_duplicate (this->orb_.in ());
ACE_Thread_Manager::instance()->spawn_n (1,
ACE_THR_FUNC (killer),
static_cast<void*> (orb));
}
}
|