proxygen
proxygen::SignalHandler Class Reference

#include <SignalHandler.h>

Inheritance diagram for proxygen::SignalHandler:
folly::AsyncSignalHandler

Public Member Functions

 SignalHandler (HTTPServer *server)
 
void install (const std::vector< int > &signals)
 

Private Member Functions

void signalReceived (int signum) noexceptoverride
 
- Private Member Functions inherited from folly::AsyncSignalHandler
 AsyncSignalHandler (EventBase *eventBase)
 
virtual ~AsyncSignalHandler ()
 
void attachEventBase (EventBase *eventBase)
 
void detachEventBase ()
 
EventBasegetEventBase () const
 
void registerSignalHandler (int signum)
 
void unregisterSignalHandler (int signum)
 

Private Attributes

HTTPServer *const server_ {nullptr}
 

Detailed Description

Installs signal handler which will stop HTTPServer when the user presses Ctrl-C. To be used if HTTPServer is the main process.

Note: Should only be created from the thread invoking HTTPServer::start().

Definition at line 25 of file SignalHandler.h.

Constructor & Destructor Documentation

proxygen::SignalHandler::SignalHandler ( HTTPServer server)
explicit

Definition at line 19 of file SignalHandler.cpp.

21  server_(server) {
22 }
HTTPServer *const server_
Definition: SignalHandler.h:34
EventBase * getEventBase() const
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
Definition: submit.h:391

Member Function Documentation

void proxygen::SignalHandler::install ( const std::vector< int > &  signals)

Definition at line 24 of file SignalHandler.cpp.

References folly::AsyncSignalHandler::registerSignalHandler().

24  {
25  for (const int& signal: signals) {
26  registerSignalHandler(signal);
27  }
28 }
void registerSignalHandler(int signum)
void proxygen::SignalHandler::signalReceived ( int  signum)
overrideprivatevirtualnoexcept

signalReceived() will called to indicate that the specified signal has been received.

signalReceived() will always be invoked from the EventBase loop (i.e., after the main POSIX signal handler has returned control to the EventBase thread).

Implements folly::AsyncSignalHandler.

Definition at line 30 of file SignalHandler.cpp.

References server_, and proxygen::HTTPServer::stop().

30 { server_->stop(); }
HTTPServer *const server_
Definition: SignalHandler.h:34

Member Data Documentation

HTTPServer* const proxygen::SignalHandler::server_ {nullptr}
private

Definition at line 34 of file SignalHandler.h.

Referenced by signalReceived().


The documentation for this class was generated from the following files: