summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_Timeout_Filter.cpp
blob: 6bc7b0afa8c2a5e38b78b51de0a4c11f0b0ceb20 (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
108
109
110
111
112
// $Id$

#include "EC_Timeout_Filter.h"
#include "EC_Timeout_Generator.h"
#include "EC_Event_Channel.h"
#include "orbsvcs/Time_Utilities.h"
#include "orbsvcs/Event_Service_Constants.h"

#if ! defined (__ACE_INLINE__)
#include "EC_Timeout_Filter.i"
#endif /* __ACE_INLINE__ */

ACE_RCSID(Event, EC_Timeout_Filter, "$Id$")

TAO_EC_Timeout_Filter::TAO_EC_Timeout_Filter (
      TAO_EC_Event_Channel *event_channel,
      const TAO_EC_QOS_Info& qos_info,
      RtecEventComm::EventType type,
      RtecEventComm::Time period)
  : event_channel_ (event_channel),
    qos_info_ (qos_info),
    type_ (type)
{
  ACE_Time_Value tv_delta;
  ORBSVCS_Time::TimeT_to_Time_Value (tv_delta, period);

  TAO_EC_Timeout_Generator *tg =
    this->event_channel_->timeout_generator ();

  if (type == ACE_ES_EVENT_INTERVAL_TIMEOUT)
    {
      ACE_Time_Value tv_interval;
      ORBSVCS_Time::TimeT_to_Time_Value (tv_interval, period);

      this->id_ =
        tg->schedule_timer (this,
                            tv_delta,
                            tv_interval);
    }
  else
    {
      this->id_ =
        tg->schedule_timer (this,
                            tv_delta,
                            ACE_Time_Value::zero);
    }

  //  ACE_DEBUG ((LM_DEBUG,
  //              "EC_Timeout_Filter - interval = %d:%d, ID = %d\n",
  //              tv_interval.sec (), tv_interval.usec (),
  //              this->id_));
}

TAO_EC_Timeout_Filter::~TAO_EC_Timeout_Filter (void)
{
  this->event_channel_->timeout_generator ()->cancel_timer (this->qos_info_,
                                                            this->id_);
}

int
TAO_EC_Timeout_Filter::filter (const RtecEventComm::EventSet& event,
                               TAO_EC_QOS_Info& qos_info,
                               CORBA::Environment& ACE_TRY_ENV)
{
  this->push (event, qos_info, ACE_TRY_ENV);
  return 1;
}

int
TAO_EC_Timeout_Filter::filter_nocopy (RtecEventComm::EventSet& event,
                                   TAO_EC_QOS_Info& qos_info,
                                   CORBA::Environment& ACE_TRY_ENV)
{
  this->push_nocopy (event, qos_info, ACE_TRY_ENV);
  return 1;
}

void
TAO_EC_Timeout_Filter::push (const RtecEventComm::EventSet& event,
                          TAO_EC_QOS_Info& qos_info,
                          CORBA::Environment& ACE_TRY_ENV)
{
  if (this->parent () != 0)
    this->parent ()->push (event, qos_info, ACE_TRY_ENV);
}

void
TAO_EC_Timeout_Filter::push_nocopy (RtecEventComm::EventSet& event,
                                 TAO_EC_QOS_Info& qos_info,
                                 CORBA::Environment& ACE_TRY_ENV)
{
  if (this->parent () != 0)
    this->parent ()->push_nocopy (event, qos_info, ACE_TRY_ENV);
}

void
TAO_EC_Timeout_Filter::clear (void)
{
}

CORBA::ULong
TAO_EC_Timeout_Filter::max_event_size (void) const
{
  return 1;
}

int
TAO_EC_Timeout_Filter::can_match (
      const RtecEventComm::EventHeader& header) const
{
  return 0;
}