summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Log/Log_Flush_Handler.cpp
blob: a17fe88dd4e6efb8ae345ec5aa646a8948fd8edc (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
#include "orbsvcs/Log/Log_Flush_Handler.h"
#include "orbsvcs/Log/Log_i.h"

ACE_RCSID (Log,
           Log_Flush_Handler,
           "$Id$")

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

TAO_Log_Flush_Handler::TAO_Log_Flush_Handler (ACE_Reactor* reactor,
                                              TAO_Log_i* log,
                                              const ACE_Time_Value& interval)
  : timer_id_(-1),
    reactor_(reactor),
    log_(log),
    interval_(interval)
{
}

TAO_Log_Flush_Handler::~TAO_Log_Flush_Handler ()
{
  this->cancel ();
}

void
TAO_Log_Flush_Handler::schedule ()
{
  this->cancel ();
  this->timer_id_ =
    this->reactor_->schedule_timer (this, 0, this->interval_, this->interval_);
}

void
TAO_Log_Flush_Handler::cancel ()
{
  if (this->timer_id_ != -1)
    {
      this->reactor_->cancel_timer (timer_id_);
      this->timer_id_ = -1;
    }
}

int
TAO_Log_Flush_Handler::handle_timeout (const ACE_Time_Value&, const void *)
{
  try
    {
      log_->flush ();
    }
  catch (const CORBA::Exception& ex)
    {
    }

  return 0;
}

TAO_END_VERSIONED_NAMESPACE_DECL