summaryrefslogtreecommitdiff
path: root/TAO/tests/NestedUpcall/Reactor/reactor_i.cpp
blob: b14fe96ae29081f882293494a091305bcadabdb2 (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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// $Id$

#include "tao/corba.h"
#include "reactor_i.h"

ACE_RCSID(Reactor, reactor_i, "$Id$")

// CTOR
Reactor_i::Reactor_i (void)
  :  quiet_ (0)
{
}

// DTOR
Reactor_i::~Reactor_i (void)
{
}

void
Reactor_i::be_quiet (int quiet)
{
  this->quiet_ = quiet;
}

// register...with nothing
CORBA::Long
Reactor_i::register_handler (EventHandler_ptr eh,
                             CORBA::Environment &ACE_TRY_ENV)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  if (!this->quiet_)
    ACE_DEBUG ((LM_DEBUG,
                "(%P|%t) BEGIN Reactor_i::register_handler ()\n"));

  CORBA::Long r = 0;

  ACE_TRY
    {
      r = eh->peer (ACE_TRY_ENV);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "getting peer");
    }
  ACE_ENDTRY;

  if (!this->quiet_)
    ACE_DEBUG ((LM_DEBUG,
                "(%P|%t) got this value from peer: %d\n",
                r));

  if (!this->quiet_)
    ACE_DEBUG ((LM_DEBUG,
                "(%P|%t) END Reactor_i::register_handler ()\n"));

  return 0;
}

void
Reactor_i::set_value (CORBA::Environment &)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  if (!this->quiet_)
    ACE_DEBUG ((LM_DEBUG,
                "(%P|%t) doing Reactor_i::set_value()\n"));
}

CORBA::UShort
Reactor_i::decrement (EventHandler_ptr eh,
                      CORBA::UShort num,
                      CORBA::Environment &env)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  if (!this->quiet_)
    ACE_DEBUG ((LM_DEBUG, "%{%I(%P|%t) Reactor::decrement (%d)%$", num));

  CORBA::UShort ret;
  if (--num <= 0)
    ret = 0;
  else
    {
      if (!this->quiet_)
        ACE_DEBUG ((LM_DEBUG,
                    "(%P|%t) Reactor::decrement() "
                    "invoking EventHandler::decrement(%d)%$", num));

      Reactor_var me = _this (env);
      ret = eh->decrement (me.in (), num, env);
    }

  if (!this->quiet_)
    ACE_DEBUG ((LM_DEBUG,
                "%}(%P|%t) Reactor::decrement() "
                "returning %d\n", ret));

  return ret;
}

void
Reactor_i::stop (CORBA::Environment &)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  // @@ TODO Keep an ORB pointer around...
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) stopping.\n"));
  TAO_ORB_Core_instance ()->orb ()->shutdown ();
}