Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / examples / Callback_Quoter / Consumer_Signal_Handler.h
blob6043fd02f4ecb3537ffc1caf4f7e79e813befbae
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Consumer_Signal_Handler.h
7 * Definition of the Consumer_Signal_Handler class.
9 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
11 //=============================================================================
14 #ifndef CONSUMER_SIGNAL_HANDLER_H
15 #define CONSUMER_SIGNAL_HANDLER_H
17 #include "ace/Reactor.h"
18 #include "ace/Event_Handler.h"
19 #include "Consumer_Handler.h"
21 class Consumer_Handler;
23 /**
24 * @class Consumer_Signal_Handler
26 * @brief Creating a class to handle signal events.
28 * Since only signals need to be handled, only the <handle_signal> method
29 * is overlaoded.
31 class Consumer_Signal_Handler : public ACE_Event_Handler
33 public:
34 /// The consumer_handler reference will be used to access the servant
35 /// methods.
36 Consumer_Signal_Handler (Consumer_Handler *consumer_handler);
38 /// This method takes action on an signal event.
39 int handle_signal (int signum,
40 siginfo_t*,
41 ucontext_t*) override;
43 /**
44 * For removal of the signal handler from the dispatch tables. When
45 * the handle_signal () returns < 0 this method will be executed
46 * automatically.
48 int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) override;
50 protected:
51 /// Protected destructor so that the signal handler is always created
52 /// dynamically and hence the heap doesnt get corrupted.
53 ~Consumer_Signal_Handler () = default;
55 private:
56 /// Exit gracefully on a signal.
57 int quit_on_signal ();
59 /// Reference to the Consumer_Handler which is used in accessing the
60 /// servant methods.
61 Consumer_Handler *consumer_handler_;
64 #endif /* CONSUMER_SIGNAL_HANDLER_H */