Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::ScopedSolveInterrupterCallback Class Reference

#include <solve_interrupter.h>

Public Member Functions

 ScopedSolveInterrupterCallback (const SolveInterrupter *interrupter, SolveInterrupter::Callback callback)
 
 ScopedSolveInterrupterCallback (const ScopedSolveInterrupterCallback &)=delete
 
ScopedSolveInterrupterCallbackoperator= (const ScopedSolveInterrupterCallback &)=delete
 
 ~ScopedSolveInterrupterCallback ()
 Removes the callback if necessary.
 
void RemoveCallbackIfNecessary ()
 
const SolveInterrupterinterrupter () const
 Returns the optional interrupter.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ScopedSolveInterrupterCallback() [1/2]

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.

◆ ScopedSolveInterrupterCallback() [2/2]

operations_research::ScopedSolveInterrupterCallback::ScopedSolveInterrupterCallback ( const ScopedSolveInterrupterCallback & )
delete

◆ ~ScopedSolveInterrupterCallback()

operations_research::ScopedSolveInterrupterCallback::~ScopedSolveInterrupterCallback ( )

Removes the callback if necessary.

Definition at line 91 of file solve_interrupter.cc.

Member Function Documentation

◆ interrupter()

const SolveInterrupter * operations_research::ScopedSolveInterrupterCallback::interrupter ( ) const
inline

Returns the optional interrupter.

Definition at line 140 of file solve_interrupter.h.

◆ operator=()

ScopedSolveInterrupterCallback & operations_research::ScopedSolveInterrupterCallback::operator= ( const ScopedSolveInterrupterCallback & )
delete

◆ RemoveCallbackIfNecessary()

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.


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