summaryrefslogtreecommitdiff
path: root/ACE/examples/APG/Timers/Upcall.h
blob: 5b2c1c7593e10e4e4de27563018317952ffc5953 (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
/* -*- C++ -*- */
#if !defined(UPCALL_H)
#define UPCALL_H

#include "ace/Timer_Queue_T.h"
#include "ace/Timer_Heap_T.h"
#include "ace/Synch.h"

#include "PCB.h"

// Listing 1 code/ch20
class UpcallHandler;

typedef ACE_Timer_Queue_T<PCB*, UpcallHandler, ACE_Null_Mutex>
  PTimerQueue;

// Create a special heap-based timer queue that allows you to
// control exactly how timer evetns are handled.
typedef ACE_Timer_Heap_T<PCB*, UpcallHandler, ACE_Null_Mutex>
  PTimerHeap;
// Listing 1

class UpcallHandler
{
public:
  // The signature of this method changed at ACE 5.4. The 'recurring_timer'
  // parameter was added.
  int timeout (PTimerQueue &timer_queue,
               PCB *handler,
               const void *arg,
               int recurring_timer,
               const ACE_Time_Value &cur_time);

#if 0
  // This method was removed at ACE 5.4. Replaced by cancel_type() and
  // cancel_timer().
  // This method is called when the timer is canceled.
  int cancellation (PTimerQueue &timer_queue,
                    PCB *handler);
#endif

  // This method is called when the timer queue is destroyed and
  // the timer is still contained in it.
  int deletion (PTimerQueue &timer_queue,
                PCB *handler,
                const void *arg);

  // The following methods don't appear before ACE 5.4, so aren't
  // referenced in APG (it's based on ACE 5.3).

  // This method is called when a timer is registered.
  int registration (PTimerQueue &timer_queue,
                    PCB *handler,
                    const void *arg);

  // This method is called before the timer expires.
  int preinvoke (PTimerQueue &timer_queue,
                 PCB *handler,
                 const void *arg,
                 int recurring_timer,
                 const ACE_Time_Value &cur_time,
                 const void *&upcall_act);

  // This method is called after the timer expires.
  int postinvoke (PTimerQueue &timer_queue,
                  PCB *handler,
                  const void *arg,
                  int recurring_timer,
                  const ACE_Time_Value &cur_time,
                  const void *upcall_act);

  // This method is called when a handler is cancelled
  int cancel_type (PTimerQueue &timer_queue,
                   PCB *handler,
                   int dont_call,
                   int &requires_reference_counting);

  // This method is called when a timer is cancelled
  int cancel_timer (PTimerQueue &timer_queue,
                    PCB *handler,
                    int dont_call,
                    int requires_reference_counting);
};

#endif /*UPCALL_H*/