Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <solve_interrupter.h>
Public Member Functions | |
ScopedSolveInterrupterCallback (const SolveInterrupter *interrupter, SolveInterrupter::Callback callback) | |
ScopedSolveInterrupterCallback (const ScopedSolveInterrupterCallback &)=delete | |
ScopedSolveInterrupterCallback & | operator= (const ScopedSolveInterrupterCallback &)=delete |
~ScopedSolveInterrupterCallback () | |
Removes the callback if necessary. | |
void | RemoveCallbackIfNecessary () |
const SolveInterrupter * | interrupter () const |
Returns the optional interrupter. | |
Class implementing RAII for interruption callbacks.
Usage:
const SolveInterrupter* const interrupter = ...; { const ScopedSolveInterrupterCallback scoped_intr_cb(interrupter, [](){ ///< Do something when/if interrupter is not nullptr and is triggered. } ... } ///< At this point, the callback will have been removed.
The function RemoveCallbackIfNecessary() can be used to remove the callback before the destruction of this object.
Definition at line 119 of file solve_interrupter.h.
operations_research::ScopedSolveInterrupterCallback::ScopedSolveInterrupterCallback | ( | const SolveInterrupter * | interrupter, |
SolveInterrupter::Callback | callback ) |
Adds a callback to the interrupter if it is not nullptr. Does nothing when interrupter is nullptr.
Definition at line 81 of file solve_interrupter.cc.
|
delete |
operations_research::ScopedSolveInterrupterCallback::~ScopedSolveInterrupterCallback | ( | ) |
Removes the callback if necessary.
Definition at line 91 of file solve_interrupter.cc.
|
inline |
Returns the optional interrupter.
Definition at line 140 of file solve_interrupter.h.
|
delete |
void operations_research::ScopedSolveInterrupterCallback::RemoveCallbackIfNecessary | ( | ) |
Removes the callback from the interrupter. If it has already been removed by a previous call or if a null interrupter was passed to the constructor, this function has no effect.
Definition at line 95 of file solve_interrupter.cc.