summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/LWFT/Timer.h
blob: a7ff1ed1400644a315b26aaf72e4fffd4ddeff78 (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
// -*- C++ -*-
// $Id$

//============================================================
/**
 * @file Timer.h
 *
 * taken from basic sp timer code
 * @author
 */
//============================================================

#ifndef TIMER_H
#define TIMER_H

#include "ace/Task.h"

#include "lwft_common_export.h"

/**
  * @class Timer
  *
  */
class LWFT_Common_Export Timer : public ACE_Task_Base
{
public:
  /// Default constructor.
  Timer (void);

  /// Default destructor.
  ~Timer (void);

  double hertz (void);
  void hertz (double h);
  void start (void);
  void stop (void);

  /// Helper function to be called back after a timeout
  virtual int pulse (void);

  ///  timer related functions including the active object svc function which
  ///  runs our timer

  /// Handle the timeout.
  virtual int handle_timeout (const ACE_Time_Value &tv,
                              const void *arg);

  /// Called when <Time_Handler> is removed.
  virtual int handle_close (ACE_HANDLE handle,
                            ACE_Reactor_Mask close_mask);

  virtual int svc (void);

protected:
  /// Flag to indicate completion of this active object.
  int done_;

  /// flag to indicate if we are already activated
  int active_;

  /// Frequency
  double hertz_;

  /// The timer id we are waiting.
  long tid_;
};

#endif /* TIMER_H */