A thread that waits for a shutdown signal and allows other modules/threads to query whether shutdown is in progress or not. More...
#include <Robots/LoBot/thread/LoShutdown.H>
Public Member Functions | |
~Shutdown () | |
Clean-up. | |
Static Public Member Functions | |
static void | start_listening () |
static bool | signaled () |
static void | signal () |
Friends | |
class | singleton< Shutdown > |
A thread that waits for a shutdown signal and allows other modules/threads to query whether shutdown is in progress or not.
This class implements a signal handling thread that simply waits for one of the SIGINT, SIGHUP, etc. signals to be sent to the Robolocust application. Once such a signal is delivered, it updates its internal state to reflect that the application is to be shutdown. All other Robolocust threads are required to monitor this Shutdown object in their respective main loops and break out of these loops when shutdown has been signaled.
Definition at line 89 of file LoShutdown.H.
lobot::Shutdown::~Shutdown | ( | ) |
Clean-up.
Definition at line 168 of file LoShutdown.C.
void lobot::Shutdown::signal | ( | ) | [static] |
Allow a client to explicitly post a SIGTERM to the shutdown thread.
Definition at line 160 of file LoShutdown.C.
References lobot::Thread::running().
bool lobot::Shutdown::signaled | ( | ) | [static] |
Let clients know whether a shutdown signal has been received or not.
Definition at line 147 of file LoShutdown.C.
References lobot::Thread::running().
Referenced by lobot::Arbiter::run(), lobot::App::run(), and lobot::Behavior::run().
void lobot::Shutdown::start_listening | ( | ) | [static] |
A convenience method for setting up the signals mask and starting the shutdown signals monitoring thread.
NOTE: This method should be called sometime early on in the application's lifetime. Moreover, it *must* be called *only* by the application's main thread.
Definition at line 97 of file LoShutdown.C.
References lobot::Thread::count().