3#if __has_include(<stop_token>)
29#if defined(__cpp_lib_jthread) && __cpp_lib_jthread >= 201911L
31#if defined(__apple_build_version__)
38#if __apple_build_version__ >= 15000000 && __apple_build_version__ < 16000000
41#define MAYAFLUX_JTHREAD_BROKEN 1
42#pragma message("ServerThread: Detected Apple Clang 15.x - using std::thread fallback for jthread")
45#define MAYAFLUX_JTHREAD_WORKING 1
49#define MAYAFLUX_JTHREAD_WORKING 1
53#define MAYAFLUX_JTHREAD_BROKEN 1
54#pragma message("ServerThread: std::jthread not available - using std::thread fallback")
59#ifdef MAYAFLUX_JTHREAD_WORKING
69 using Callback = std::function<void(
const std::stop_token&)>;
96 [[nodiscard]]
bool joinable()
const noexcept
153 m_thread = std::thread([callback = std::move(callback), stop_flag]() {
160 :
m_thread(std::move(other.m_thread))
167 if (
this != &other) {
173 m_thread = std::move(other.m_thread);
194 m_stop_flag->store(
true, std::memory_order_release);
static MayaFlux::Nodes::ProcessingToken token
bool stop_requested() const noexcept
const std::atomic< bool > * m_stop_flag
StopToken(const std::atomic< bool > *stop_flag)
API-compatible stop token for platforms without std::stop_token.
void request_stop() noexcept
std::shared_ptr< std::atomic< bool > > m_stop_flag
ServerThread(ServerThread &&other) noexcept
ServerThread & operator=(const ServerThread &)=delete
ServerThread(Callback callback)
std::function< void(const StopToken &)> Callback
ServerThread & operator=(ServerThread &&other) noexcept
ServerThread(const ServerThread &)=delete
bool joinable() const noexcept
Fallback std::thread-based thread wrapper with manual stop signaling.