summaryrefslogtreecommitdiff
path: root/orbsvcs/orbsvcs/Log/Iterator_i.cpp
blob: 1030312d93eb1f3cda63878fd887eaff0d4dcc8d (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
// $Id$

#include "orbsvcs/Log/Iterator_i.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

// iterator inactivity timeout
ACE_Time_Value
TAO_Iterator_i::timeout_(60 * 60);

TAO_Iterator_i::TAO_Iterator_i (PortableServer::POA_ptr poa,
                                ACE_Reactor* reactor)
  : poa_ (PortableServer::POA::_duplicate (poa)),
    reactor_ (reactor)
{
   if (this->timeout_ != ACE_Time_Value::zero)
     {
       this->timer_id_ =
         this->reactor_->schedule_timer (this, 0, this->timeout_);
     }
}


TAO_Iterator_i::~TAO_Iterator_i (void)
{
  // cancel timer
  if (this->timer_id_ != -1)
    {
      this->reactor_->cancel_timer (this->timer_id_);
    }
}


void
TAO_Iterator_i::destroy (void)
{
  PortableServer::ObjectId_var oid =
    this->poa_->servant_to_id (this);

  // Goodbye cruel world...
  // deactivate from the poa.
  this->poa_->deactivate_object (oid.in ());
  return;
}


int
TAO_Iterator_i::handle_timeout(const ACE_Time_Value&, const void*)
{
  try
    {
      this->destroy ();
    }
  catch (const CORBA::Exception&)
    {
    }

  return 0;
}

TAO_END_VERSIONED_NAMESPACE_DECL