MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Lila::ServerThread Class Reference

Fallback std::thread-based thread wrapper with manual stop signaling. More...

#include <ServerThread.hpp>

+ Collaboration diagram for Lila::ServerThread:

Classes

class  StopToken
 API-compatible stop token for platforms without std::stop_token. More...
 

Public Types

using Callback = std::function< void(const StopToken &)>
 

Public Member Functions

 ServerThread ()=default
 
 ServerThread (Callback callback)
 
 ServerThread (ServerThread &&other) noexcept
 
ServerThreadoperator= (ServerThread &&other) noexcept
 
 ServerThread (const ServerThread &)=delete
 
ServerThreadoperator= (const ServerThread &)=delete
 
 ~ServerThread ()
 
void request_stop () noexcept
 
void join ()
 
bool joinable () const noexcept
 

Private Attributes

std::thread m_thread
 
std::shared_ptr< std::atomic< bool > > m_stop_flag
 

Detailed Description

Fallback std::thread-based thread wrapper with manual stop signaling.

Compatible implementation for platforms where std::jthread is unavailable or broken. Provides identical interface using std::thread + std::atomic<bool> for stop signaling.

Implementation Notes:

  • StopToken provides API-compatible interface with std::stop_token
  • Uses shared_ptr<atomic<bool>> to ensure stop flag outlives thread
  • Memory ordering: acquire on read, release on write (matches std::stop_token semantics)
  • Minimal overhead: one atomic load per loop iteration (~1-2 CPU cycles)

Definition at line 119 of file ServerThread.hpp.


The documentation for this class was generated from the following file: