summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.h
blob: 3986dc982da2eba8e210ec26f970a1e639d95635 (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
// $Id$

/**
 * @file Pulser.h
 *
 * Header file for the Pulser class.
 *
 * @author Nanbor Wang <nanbor@cse.wustl.edu>
 */

#ifndef PULSER_H
#define PULSER_H

#include "tao/corba.h"
#include "ace/Thread_Manager.h"
#include "ace/Task.h"

namespace PTImpl
{
  // Forward decl.
  class Pulse_Handler
  {
  public:
    /// Helper function to be called back by Pulse_Handler
    virtual void pulse (void) = 0;
  };

  /**
   * @brief Active pulse generater
   */
  class Pulser : public ACE_Task_Base
  {
  public:
    // Default constructor
    Pulser (Pulse_Handler *cb);
    ~Pulser ();

    int open (void *args = 0);

    int close (u_long flags = 0);

    int start (CORBA::Long hertz);

    int stop (void);

    int active (void);

    // 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);

  private:
    /// Tracking whether we are actively generating pulse or not.
    long active_;

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

    /// The timer id we are waiting.
    int tid_;

    Pulse_Handler *pulser_callback_;

    ACE_Thread_Manager thr_mgr_;
  };

}

#endif /* PULSER_H */