summaryrefslogtreecommitdiff
path: root/TAO/tests/Bug_2654_Regression/Hello.cpp
blob: 70c29c92ddc53b979955096ebfa873f42899d1cf (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
55
//
// $Id$
//
#include "Hello.h"
#include "ace/Task.h"

class Killer : public ACE_Task_Base
{
public:
  Killer (CORBA::ORB_ptr orb)
  : orb_ (CORBA::ORB::_duplicate (orb))
  {
  }

  int svc (void)
  {
    ACE_DEBUG ((LM_DEBUG,"(%P|%t) server exiting\n"));
    this->orb_->shutdown (1);
    return 0;
  }

private:
  CORBA::ORB_var orb_;
};

Hello::Hello (CORBA::ORB_ptr orb)
  : orb_ (CORBA::ORB::_duplicate (orb)),
    count_(0)

{
}

void
Hello::set_callback (Test::CallBack_ptr cb)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  ACE_DEBUG ((LM_DEBUG,"(%P|%t) got callback \n"));
  this->callback_ = Test::CallBack::_duplicate(cb);
  this->callback_->method2();
}

void
Hello::method (CORBA::Short count)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  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);
      Killer *k = new Killer (orb_.in ());
      k->activate();
    }
}