Interupt monitor for long computations.
An MComputation allows long computations to check for user interrupts. It is very simple to use. Create a new MComputation object and call the beginComputation method at the beginning of the computation and call the endComputation method when you finish. Then, during the computation, use the isInterruptRequested method to check if the user has requested that the computation terminate.
Example: (of a simple traversal)
MComputation computation; computation.beginComputation(); for (int i= 1; i<1000; i++) { Computation(); // Some expensive operation if (computation.isInterruptRequested()) break ; } computation.endComputation();
#include <MComputation.h>
Public Member Functions |
|
MComputation () | |
Constructor for MComputation.
|
|
virtual | ~MComputation () |
Class destructor. |
|
void | beginComputation () |
Mark the beginning of a long computation.
|
|
bool | isInterruptRequested () |
Query whether a user-interrupt has occurred.
|
|
void | endComputation () |
Mark the ending of a long computation.
|
|
Static Public Member Functions |
|
static const char * | className () |
Returns the name of this class. |
MComputation | ( | ) |
Constructor for MComputation.
Instantiate an MComputation before entering a long computation that should be interruptible.
void beginComputation | ( | ) |
Mark the beginning of a long computation.
The application will begin looking for user interupts.
bool isInterruptRequested | ( | ) |
Query whether a user-interrupt has occurred.
void endComputation | ( | ) |
Mark the ending of a long computation.
The application will stop looking for user interupts.
const char * className | ( | ) | [static] |