PGROUTING  3.2
SignalHandler Class Reference

#include "signalhandler.h"

Collaboration diagram for SignalHandler:

Public Member Functions

EventHandlerregisterHandler (int signum, EventHandler *eh)
 
void removeHandler (int signum)
 

Static Public Member Functions

static SignalHandlerinstance (void)
 

Private Member Functions

 SignalHandler (void)
 

Static Private Member Functions

static void dispatcher (int signum)
 

Static Private Attributes

static SignalHandlerinstance_ = NULL
 
static EventHandlersignalHandlers_ [NSIG]
 

Detailed Description

Definition at line 70 of file signalhandler.h.

Constructor & Destructor Documentation

◆ SignalHandler()

SignalHandler::SignalHandler ( void  )
inlineprivate

Definition at line 87 of file signalhandler.h.

87 {}

Referenced by instance().

Member Function Documentation

◆ dispatcher()

void SignalHandler::dispatcher ( int  signum)
staticprivate

Definition at line 73 of file signalhandler.cpp.

73  {
74  // Perform a sanity check...
75  if (SignalHandler::signalHandlers_[signum] != 0)
76  // Dispatch the handler's hook method.
78 }

References EventHandler::handleSignal(), and signalHandlers_.

Referenced by registerHandler().

◆ instance()

SignalHandler * SignalHandler::instance ( void  )
static

Definition at line 38 of file signalhandler.cpp.

38  {
39  if (!instance_) instance_ = new SignalHandler;
40 
41  // assert(instance_ != NULL);
42  return instance_;
43 }

References instance_, and SignalHandler().

◆ registerHandler()

EventHandler * SignalHandler::registerHandler ( int  signum,
EventHandler eh 
)

Definition at line 47 of file signalhandler.cpp.

47  {
48  // Copy the <old_eh> from the <signum> slot in
49  // the <signalHandlers_> table.
50  EventHandler *old_eh = signalHandlers_[signum];
51 
52  // Store <eh> into the <signum> slot in the
53  // <signalHandlers_> table.
54  SignalHandler::signalHandlers_[signum] = eh;
55 
56  // Register the <dispatcher> to handle this
57  // <signum>.
58  struct sigaction sa;
59  sa.sa_handler = SignalHandler::dispatcher;
60  sigemptyset(&sa.sa_mask);
61  sa.sa_flags = 0;
62  sigaction(signum, &sa, 0);
63 
64  return old_eh;
65 }

References dispatcher(), and signalHandlers_.

◆ removeHandler()

void SignalHandler::removeHandler ( int  signum)

Definition at line 67 of file signalhandler.cpp.

67  {
68  // EventHandler *old_eh = signalHandlers_[signum];
69  signalHandlers_[signum] = static_cast<EventHandler *>(0);
70 }

References signalHandlers_.

Member Data Documentation

◆ instance_

SignalHandler * SignalHandler::instance_ = NULL
staticprivate

Definition at line 90 of file signalhandler.h.

Referenced by instance().

◆ signalHandlers_

EventHandler * SignalHandler::signalHandlers_
staticprivate

Definition at line 100 of file signalhandler.h.

Referenced by dispatcher(), registerHandler(), and removeHandler().


The documentation for this class was generated from the following files:
SignalHandler::SignalHandler
SignalHandler(void)
Definition: signalhandler.h:87
SignalHandler::dispatcher
static void dispatcher(int signum)
Definition: signalhandler.cpp:73
SignalHandler::signalHandlers_
static EventHandler * signalHandlers_[NSIG]
Definition: signalhandler.h:100
EventHandler::handleSignal
virtual void handleSignal(int signum)=0
SignalHandler::instance_
static SignalHandler * instance_
Definition: signalhandler.h:90
EventHandler
Definition: signalhandler.h:59