41#ifndef OPENSWMM_ENGINE_IO_THREAD_HPP
42#define OPENSWMM_ENGINE_IO_THREAD_HPP
48#include <condition_variable>
114 bool running() const noexcept {
return running_.load(std::memory_order_relaxed); }
117 int tasks_completed() const noexcept {
return tasks_completed_.load(std::memory_order_relaxed); }
120 int last_error() const noexcept {
return last_error_.load(std::memory_order_relaxed); }
126 const std::size_t capacity_;
129 std::queue<WriteTask> queue_;
131 std::condition_variable cv_not_full_;
132 std::condition_variable cv_not_empty_;
133 std::atomic<bool> stop_flag_ {
false};
134 std::atomic<bool> running_ {
false};
135 std::atomic<int> tasks_completed_{0};
136 std::atomic<int> last_error_ {0};
137 int next_sequence_ = 0;
Ring-buffer task descriptor for the IO thread (Phase 5, R17).
Producer-consumer IO thread for writing simulation snapshots.
Definition IOThread.hpp:64
void stop()
Signal the IO thread to finish and join it.
Definition IOThread.cpp:65
int tasks_completed() const noexcept
Number of tasks processed so far.
Definition IOThread.hpp:117
static constexpr std::size_t DEFAULT_QUEUE_CAPACITY
Default maximum queue depth.
Definition IOThread.hpp:67
void start()
Start the IO worker thread.
Definition IOThread.cpp:35
~IOThread()
Definition IOThread.cpp:27
bool running() const noexcept
True if the thread is running.
Definition IOThread.hpp:114
void post(SimulationSnapshot snap)
Post a snapshot to the write queue.
Definition IOThread.cpp:45
int last_error() const noexcept
Last error code from a plugin update (0 = no error).
Definition IOThread.hpp:120
IOThread & operator=(const IOThread &)=delete
IOThread(const IOThread &)=delete
Manages all dynamically loaded plugins for one engine instance.
Definition PluginFactory.hpp:72
Definition Controls.cpp:24
Complete simulation state snapshot at one output time step.
Definition SimulationSnapshot.hpp:90