Clingo
Loading...
Searching...
No Matches
sync.hh
1#pragma once
2
3#include <atomic>
4
5namespace CppClingo::Util {
6
11class StopFlag {
12 public:
14 StopFlag() noexcept = default;
16 StopFlag(StopFlag const &other) = delete;
18 StopFlag(StopFlag &&other) noexcept = delete;
20 auto operator=(StopFlag const &other) -> StopFlag & = delete;
22 auto operator=(StopFlag &&other) noexcept -> StopFlag & = delete;
23
25 void request_stop() noexcept { state_.store(true, std::memory_order_relaxed); }
27 [[nodiscard]] auto stop_requested() noexcept -> bool { return state_.load(std::memory_order_relaxed); }
28
29 private:
30 std::atomic<bool> state_ = false;
31};
32
33} // namespace CppClingo::Util
Helper class to signal stopping of grounding.
Definition sync.hh:11
auto stop_requested() noexcept -> bool
Test whether stopping has been requested.
Definition sync.hh:27
StopFlag() noexcept=default
Construct a false stop flag.
void request_stop() noexcept
Set the stop flag.
Definition sync.hh:25