File: Timer.h

package info (click to toggle)
ace 6.0.3%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 49,368 kB
  • sloc: cpp: 341,826; perl: 30,850; ansic: 20,952; makefile: 10,144; sh: 4,744; python: 828; exp: 787; yacc: 511; xml: 330; lex: 158; lisp: 116; csh: 48; tcl: 5
file content (94 lines) | stat: -rw-r--r-- 2,742 bytes parent folder | download | duplicates (2)
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
/* -*- c++ -*- */
// $Id: Timer.h 91743 2010-09-13 18:24:51Z johnnyw $

#ifndef JAWS_TIMER_H
#define JAWS_TIMER_H

#include "ace/Singleton.h"
#include "ace/Timer_Wheel.h"
#include "ace/Timer_Queue_Adapters.h"

#include "jaws3/Export.h"
#include "jaws3/Event_Completer.h"

class JAWS_Timer;
class JAWS_Timer_Impl;

class JAWS_Export JAWS_Timer_Impl
// = TITLE
//     Implementation base class for Timers that corresponds to the
//     RHS of the Bridge pattern.
{
public:

  virtual ~JAWS_Timer_Impl (void) {}

  virtual void schedule_timer ( long *timer_id
                              , const ACE_Time_Value &delta
                              , JAWS_Event_Completer *completer
                              , void *act = 0
                              ) = 0;
  // Schedule a timer to expire at now+delta.

  virtual void schedule_absolute_timer ( long *timer_id
                                       , const ACE_Time_Value &tv
                                       , JAWS_Event_Completer *completer
                                       , void *act = 0
                                       ) = 0;
  // Schedule a timer to expire at tv.

  virtual void schedule_interval_timer ( long *timer_id
                                       , const ACE_Time_Value &interval
                                       , JAWS_Event_Completer *completer
                                       , void *act = 0
                                       ) = 0;
  // Schedule a timer to expire at now+interval, and every interval following.

  virtual void cancel_timer (long timer_id) = 0;
  // Cancel a timer.

};


class JAWS_Export JAWS_Timer
// = TITLE
//     Abstraction base class for Timers that corresponds to the LHS of the
//     Bridge pattern.
{
public:

  JAWS_Timer (JAWS_Timer_Impl *impl = 0);

  static JAWS_Timer * instance (void)
  {
    return ACE_Singleton<JAWS_Timer, ACE_SYNCH_MUTEX>::instance ();
  }

  void schedule_timer ( long *timer_id
                      , const ACE_Time_Value &delta
                      , JAWS_Event_Completer *completer
                      , void *act = 0
                      );

  void schedule_absolute_timer ( long *timer_id
                               , const ACE_Time_Value &tv
                               , JAWS_Event_Completer *completer
                               , void *act = 0
                               );

  void schedule_interval_timer ( long *timer_id
                               , const ACE_Time_Value &interval
                               , JAWS_Event_Completer *completer
                               , void *act = 0
                               );

  void cancel_timer (long timer_id);

private:

  JAWS_Timer_Impl *impl_;

};


#endif /* JAWS_TIMER_H */