alpaqa 1.0.0a8
Nonconvex constrained optimization
Loading...
Searching...
No Matches
atomic-stop-signal.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4
5namespace alpaqa {
6
8 public:
9 AtomicStopSignal() = default;
14
15 void stop() { stop_flag.store(true, std::memory_order_relaxed); }
16 bool stop_requested() const {
17 return stop_flag.load(std::memory_order_relaxed);
18 }
19
20 private:
21 std::atomic<bool> stop_flag{false};
22};
23
24} // namespace alpaqa
AtomicStopSignal(const AtomicStopSignal &)
AtomicStopSignal & operator=(const AtomicStopSignal &)=delete
AtomicStopSignal(AtomicStopSignal &&)
AtomicStopSignal & operator=(AtomicStopSignal &&)
std::atomic< bool > stop_flag