summaryrefslogtreecommitdiff
path: root/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.h
blob: e831ac5fa1f0de7900b50e528dbdd757bc2f49f9 (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
/* -*- C++ -*- */
// $Id$

// ===========================================================
//
//
// = LIBRARY
//    TAO/examples/Callback_Quoter
//
// = FILENAME
//    Consumer_Input_Handler.h
//
// = DESCRIPTION
//    Definition of the Consumer_Signal_Handler class.
//
// = AUTHOR
//    Kirthika Parameswaran <kirthika@cs.wustl.edu>
//
// ===========================================================

#ifndef CONSUMER_SIGNAL_HANDLER_H
#define CONSUMER_SIGNAL_HANDLER_H

#include <signal.h>
#include <ace/Reactor.h>
#include <ace/Event_Handler.h>
#include "Consumer_Handler.h"

// Creating a class to handle signal events.
// Since only signals need to be handled, only the handle_signal
// method is overlaoded.

class Consumer_Handler;

class Consumer_Signal_Handler : public ACE_Event_Handler
{
 public:

  Consumer_Signal_Handler (Consumer_Handler *consumer_handler);
  // The consumer_handler refernce will be used to access
  // the servant methods.

  int handle_signal (int signum,
			     siginfo_t*,
			     ucontext_t*);
  // This method takes action on an signal event.

  int handle_close (ACE_HANDLE handle,
			    ACE_Reactor_Mask close_mask);
  // For removal of the signal handler from the dispatch tables.
  // When the handle_signal () returns < 0 this method will
  // be executed automatically.

  friend class ACE_Shutup_GPlusPlus;
  // Turn off g++ warning

private:

  ~Consumer_Signal_Handler ();
  // private destructor so that the signal handler is
  // always created dynamically and hence the heap doesnt
  // get corrupted.

  int quit_on_signal ();
  // Exit gracefully on a signal.

  Consumer_Handler *consumer_handler_;
  // Reference to the Consumer_Handler which is used in
  // accessing the servant methods.x

};

#endif /* CONSUMER_SIGNAL_HANDLER_H */