summaryrefslogtreecommitdiff
path: root/TAO/tao/Reactive_Flushing_Strategy.cpp
blob: e75f8079e6e6d806314f56bee87d4a053dedf10d (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
// -*- C++ -*-
// $Id$

#include "Reactive_Flushing_Strategy.h"
#include "Transport.h"
#include "ORB_Core.h"
#include "Queued_Message.h"
#include "debug.h"

ACE_RCSID(tao, Reactive_Flushing_Strategy, "$Id$")

int
TAO_Reactive_Flushing_Strategy::schedule_output (TAO_Transport *transport)
{
  ACE_Reactor *reactor =
    transport->orb_core ()->reactor ();

  if (TAO_debug_level > 3)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "TAO (%P|%t) - Reactive_Flushing_Strategy[%d]::schedule_output\n",
                  transport->handle ()));
    }

  return reactor->schedule_wakeup (transport->event_handler (),
                                   ACE_Event_Handler::WRITE_MASK);
}

int
TAO_Reactive_Flushing_Strategy::cancel_output (TAO_Transport *transport)
{
  ACE_Reactor *reactor =
    transport->event_handler ()->reactor ();

  if (TAO_debug_level > 3)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "TAO (%P|%t) - Reactive_Flushing_Strategy[%d]::cancel_output\n",
                  transport->handle ()));
    }

  return reactor->cancel_wakeup (transport->event_handler (),
                                 ACE_Event_Handler::WRITE_MASK);
}

int
TAO_Reactive_Flushing_Strategy::flush_message (TAO_Transport *transport,
                                               TAO_Queued_Message *msg)
{
  TAO_ORB_Core *orb_core = transport->orb_core ();

  int result = 0;
  // @@ Should we pass this down?  Can we?
  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      while (!msg->done () && result > 0)
        {
          result = orb_core->run (0, 1, ACE_TRY_ENV);
          ACE_TRY_CHECK;
        }
    }
  ACE_CATCHANY
    {
      return -1;
    }
  ACE_ENDTRY;

  return result;
}