14#ifndef OR_TOOLS_UTIL_SOLVE_INTERRUPTER_H_
15#define OR_TOOLS_UTIL_SOLVE_INTERRUPTER_H_
22#include "absl/base/thread_annotations.h"
23#include "absl/synchronization/mutex.h"
91 std::atomic<bool> interrupted_ =
false;
93 mutable absl::Mutex mutex_;
96 mutable CallbackId next_callback_id_ ABSL_GUARDED_BY(mutex_) = {};
101 ABSL_GUARDED_BY(mutex_);
147 std::optional<SolveInterrupter::CallbackId> callback_id_;
void RemoveCallbackIfNecessary()
~ScopedSolveInterrupterCallback()
Removes the callback if necessary.
const SolveInterrupter * interrupter() const
Returns the optional interrupter.
ScopedSolveInterrupterCallback(const ScopedSolveInterrupterCallback &)=delete
ScopedSolveInterrupterCallback(const SolveInterrupter *interrupter, SolveInterrupter::Callback callback)
ScopedSolveInterrupterCallback & operator=(const ScopedSolveInterrupterCallback &)=delete
void RemoveInterruptionCallback(CallbackId id) const
SolveInterrupter()=default
SolveInterrupter & operator=(const SolveInterrupter &)=delete
std::function< void()> Callback
bool IsInterrupted() const
CallbackId AddInterruptionCallback(Callback callback) const
DEFINE_STRONG_INT_TYPE(CallbackId, int64_t)
Id used to identify a callback.
SolveInterrupter(const SolveInterrupter &)=delete
In SWIG mode, we don't want anything besides these top-level includes.