22#include "absl/synchronization/mutex.h"
30 const absl::MutexLock lock(&mutex_);
35 if (interrupted_.load()) {
49 for (
const auto& [callback_id,
callback] : callbacks_) {
56 const absl::MutexLock lock(&mutex_);
66 if (interrupted_.load()) {
70 const CallbackId
id = next_callback_id_;
72 CHECK(callbacks_.try_emplace(
id, std::move(
callback)).second);
77 const absl::MutexLock lock(&mutex_);
78 CHECK_EQ(callbacks_.erase(
id), 1) <<
"unregistered callback id: " << id;
84 : interrupter_(interrupter),
86 interrupter != nullptr
88 interrupter->AddInterruptionCallback(
std::move(
callback)))
97 CHECK_NE(interrupter_,
nullptr);
void RemoveCallbackIfNecessary()
~ScopedSolveInterrupterCallback()
Removes the callback if necessary.
ScopedSolveInterrupterCallback(const SolveInterrupter *interrupter, SolveInterrupter::Callback callback)
void RemoveInterruptionCallback(CallbackId id) const
std::function< void()> Callback
CallbackId AddInterruptionCallback(Callback callback) const
In SWIG mode, we don't want anything besides these top-level includes.