Class to watch for user-interrupt (SIGINT, ctrl-C) More...
#include <MsqInterrupt.hpp>
Public Member Functions | |
MsqInterrupt () | |
Constructor, increment instance count. More... | |
~MsqInterrupt () | |
Constructor, decrement instance count. More... | |
MsqInterrupt () | |
Constructor, increment instance count. More... | |
~MsqInterrupt () | |
Constructor, decrement instance count. More... | |
Static Public Member Functions | |
static void | disable (MsqError &err) |
Disable Mesquite's SIGINT handler. More... | |
static void | allow (MsqError &err) |
Allow Mesquite to register a SIGINT handler. More... | |
static void | enable (MsqError &err) |
Force Mesquite to register SIGINT handler. More... | |
static bool | interrupt () |
Check if an interrupt was seen. More... | |
static void | clear () |
Clear the interrupt flag. More... | |
static void | set_interrupt () |
Set the interrupt flag. More... | |
static void | set_handler () |
static void | disable (MsqError &err) |
Disable Mesquite's SIGINT handler. More... | |
static void | allow (MsqError &err) |
Allow Mesquite to register a SIGINT handler. More... | |
static void | enable (MsqError &err) |
Force Mesquite to register SIGINT handler. More... | |
static bool | interrupt () |
Check if an interrupt was seen. More... | |
static void | clear () |
Clear the interrupt flag. More... | |
static void | set_interrupt () |
Set the interrupt flag. More... | |
static void | set_handler () |
Private Types | |
enum | InterruptMode { CATCH, IGNORE, AUTO, CATCH, IGNORE, AUTO } |
enum | InterruptMode { CATCH, IGNORE, AUTO, CATCH, IGNORE, AUTO } |
Private Member Functions | |
void * | operator new (size_t size) |
MsqInterrupt (const MsqInterrupt &) | |
MsqInterrupt & | operator= (const MsqInterrupt &) |
void * | operator new (size_t size) |
MsqInterrupt (const MsqInterrupt &) | |
MsqInterrupt & | operator= (const MsqInterrupt &) |
Static Private Attributes | |
static InterruptMode | interruptMode = MsqInterrupt::AUTO |
static unsigned | instanceCount = 0 |
static bool | sawInterrupt = false |
Class to watch for user-interrupt (SIGINT, ctrl-C)
A class to watch for SIGINT.
Creating an instance of the class ensures that the Mesquite handler for SIGINT is registered. When all instances are destroyed, the Mesquite handler is removed. The intent is that each interruptable API declare an instance on the stack. This way the handler is automatically unregistered when the API returns. For example: void my_api( MsqError& err ) { MsqInterrupt interrupt; ... //do stuff return; }
Definition at line 51 of file includeLinks/MsqInterrupt.hpp.
|
private |
Enumerator | |
---|---|
CATCH | |
IGNORE | |
AUTO | |
CATCH | |
IGNORE | |
AUTO |
Definition at line 80 of file includeLinks/MsqInterrupt.hpp.
|
private |
Enumerator | |
---|---|
CATCH | |
IGNORE | |
AUTO | |
CATCH | |
IGNORE | |
AUTO |
Definition at line 80 of file src/Misc/MsqInterrupt.hpp.
MsqInterrupt | ( | ) |
Constructor, increment instance count.
If instance count was zero, register SIGINT handler
Definition at line 85 of file Misc/MsqInterrupt.cpp.
References MsqInterrupt::IGNORE, MsqInterrupt::instanceCount, MsqInterrupt::interruptMode, MsqInterrupt::sawInterrupt, and MsqInterrupt::set_handler().
~MsqInterrupt | ( | ) |
Constructor, decrement instance count.
If instance count goes to zero, remove SIGINT handler
Definition at line 96 of file Misc/MsqInterrupt.cpp.
References MsqInterrupt::instanceCount, Mesquite::oldHandler, and MsqInterrupt::sawInterrupt.
|
private |
MsqInterrupt | ( | ) |
Constructor, increment instance count.
If instance count was zero, register SIGINT handler
~MsqInterrupt | ( | ) |
Constructor, decrement instance count.
If instance count goes to zero, remove SIGINT handler
|
private |
|
static |
Allow Mesquite to register a SIGINT handler.
Definition at line 77 of file Misc/MsqInterrupt.cpp.
References MsqInterrupt::AUTO, MsqInterrupt::instanceCount, MsqInterrupt::interruptMode, Mesquite::oldHandler, MsqInterrupt::sawInterrupt, and MsqInterrupt::set_handler().
|
inlinestatic |
Clear the interrupt flag.
Definition at line 65 of file includeLinks/MsqInterrupt.hpp.
References MsqInterrupt::sawInterrupt.
|
inlinestatic |
Clear the interrupt flag.
Definition at line 65 of file src/Misc/MsqInterrupt.hpp.
References MsqInterrupt::sawInterrupt.
|
static |
Disable Mesquite's SIGINT handler.
Definition at line 58 of file Misc/MsqInterrupt.cpp.
References MsqInterrupt::IGNORE, MsqInterrupt::instanceCount, MsqInterrupt::interruptMode, Mesquite::oldHandler, and MsqInterrupt::sawInterrupt.
|
static |
Force Mesquite to register SIGINT handler.
Definition at line 69 of file Misc/MsqInterrupt.cpp.
References MsqInterrupt::CATCH, MsqInterrupt::instanceCount, MsqInterrupt::interruptMode, Mesquite::oldHandler, MsqInterrupt::sawInterrupt, and MsqInterrupt::set_handler().
|
inlinestatic |
Check if an interrupt was seen.
Definition at line 63 of file includeLinks/MsqInterrupt.hpp.
References MsqInterrupt::sawInterrupt.
Referenced by TerminationCriterion::terminate().
|
inlinestatic |
Check if an interrupt was seen.
Definition at line 63 of file src/Misc/MsqInterrupt.hpp.
References MsqInterrupt::sawInterrupt.
|
private |
|
private |
|
private |
|
private |
|
static |
|
static |
Definition at line 47 of file Misc/MsqInterrupt.cpp.
References MsqInterrupt::AUTO, MsqInterrupt::interruptMode, Mesquite::msq_sigint_handler(), and Mesquite::oldHandler.
Referenced by MsqInterrupt::allow(), MsqInterrupt::enable(), Mesquite::msq_sigint_handler(), and MsqInterrupt::MsqInterrupt().
|
inlinestatic |
Set the interrupt flag.
Definition at line 67 of file includeLinks/MsqInterrupt.hpp.
References MsqInterrupt::sawInterrupt.
Referenced by Mesquite::msq_sigint_handler().
|
inlinestatic |
Set the interrupt flag.
Definition at line 67 of file src/Misc/MsqInterrupt.hpp.
References MsqInterrupt::sawInterrupt.
|
staticprivate |
Definition at line 83 of file includeLinks/MsqInterrupt.hpp.
Referenced by MsqInterrupt::allow(), MsqInterrupt::disable(), MsqInterrupt::enable(), MsqInterrupt::MsqInterrupt(), and MsqInterrupt::~MsqInterrupt().
|
staticprivate |
Definition at line 82 of file includeLinks/MsqInterrupt.hpp.
Referenced by MsqInterrupt::allow(), MsqInterrupt::disable(), MsqInterrupt::enable(), MsqInterrupt::MsqInterrupt(), and MsqInterrupt::set_handler().
|
staticprivate |
Definition at line 84 of file includeLinks/MsqInterrupt.hpp.
Referenced by MsqInterrupt::allow(), MsqInterrupt::clear(), MsqInterrupt::disable(), MsqInterrupt::enable(), MsqInterrupt::interrupt(), MsqInterrupt::MsqInterrupt(), MsqInterrupt::set_interrupt(), and MsqInterrupt::~MsqInterrupt().