57#ifndef OPENSWMM_ENGINE_IO_THREAD_HPP
58#define OPENSWMM_ENGINE_IO_THREAD_HPP
64#include <condition_variable>
130 bool running() const noexcept {
return running_.load(std::memory_order_relaxed); }
133 int tasks_completed() const noexcept {
return tasks_completed_.load(std::memory_order_relaxed); }
136 int last_error() const noexcept {
return last_error_.load(std::memory_order_relaxed); }
142 const std::size_t capacity_;
145 std::queue<WriteTask> queue_;
147 std::condition_variable cv_not_full_;
148 std::condition_variable cv_not_empty_;
149 std::atomic<bool> stop_flag_ {
false};
150 std::atomic<bool> running_ {
false};
151 std::atomic<int> tasks_completed_{0};
152 std::atomic<int> last_error_ {0};
153 int next_sequence_ = 0;
Ring-buffer task descriptor for the IO thread (Phase 5, R17).
void stop()
Signal the IO thread to finish and join it.
Definition IOThread.cpp:120
int tasks_completed() const noexcept
Number of tasks processed so far.
Definition IOThread.hpp:133
static constexpr std::size_t DEFAULT_QUEUE_CAPACITY
Default maximum queue depth.
Definition IOThread.hpp:83
void start()
Start the IO worker thread.
Definition IOThread.cpp:90
IOThread(PluginFactory &factory, std::size_t capacity=DEFAULT_QUEUE_CAPACITY)
Construct (does NOT start the thread).
Definition IOThread.cpp:77
~IOThread()
Definition IOThread.cpp:82
bool running() const noexcept
True if the thread is running.
Definition IOThread.hpp:130
void post(SimulationSnapshot snap)
Post a snapshot to the write queue.
Definition IOThread.cpp:100
int last_error() const noexcept
Last error code from a plugin update (0 = no error).
Definition IOThread.hpp:136
IOThread & operator=(const IOThread &)=delete
IOThread(const IOThread &)=delete
Manages plugin discovery, loading, and lifecycle for one engine instance.
Definition PluginFactory.hpp:88
Definition NodeCoupling.cpp:16
Complete simulation state snapshot at one output time step.
Definition SimulationSnapshot.hpp:117