Producer-consumer IO thread for writing simulation snapshots.
More...
#include <IOThread.hpp>
Producer-consumer IO thread for writing simulation snapshots.
One IOThread per SWMMEngine instance. Shared with PluginFactory.
◆ IOThread() [1/2]
Construct (does NOT start the thread).
- Parameters
-
| factory | Plugin factory whose update_all() is called per task. |
| capacity | Maximum number of queued snapshots before post() blocks. |
◆ ~IOThread()
| openswmm::IOThread::~IOThread |
( |
| ) |
|
◆ IOThread() [2/2]
| openswmm::IOThread::IOThread |
( |
const IOThread & |
| ) |
|
|
delete |
◆ last_error()
| int openswmm::IOThread::last_error |
( |
| ) |
const |
|
inlinenoexcept |
Last error code from a plugin update (0 = no error).
◆ operator=()
◆ post()
Post a snapshot to the write queue.
Blocks if the queue is at capacity. Thread-safe.
- Parameters
-
| snap | Snapshot to write (moved into the queue). |
◆ running()
| bool openswmm::IOThread::running |
( |
| ) |
const |
|
inlinenoexcept |
True if the thread is running.
◆ start()
| void openswmm::IOThread::start |
( |
| ) |
|
Start the IO worker thread.
- Precondition
- Thread must not already be running.
◆ stop()
| void openswmm::IOThread::stop |
( |
| ) |
|
Signal the IO thread to finish and join it.
Waits for all queued tasks to be processed, then joins the thread. Safe to call even if start() was never called.
◆ tasks_completed()
| int openswmm::IOThread::tasks_completed |
( |
| ) |
const |
|
inlinenoexcept |
Number of tasks processed so far.
◆ DEFAULT_QUEUE_CAPACITY
| constexpr std::size_t openswmm::IOThread::DEFAULT_QUEUE_CAPACITY = 8 |
|
staticconstexpr |
Default maximum queue depth.
The documentation for this class was generated from the following files:
- /home/runner/work/openswmm.engine/openswmm.engine/src/engine/output/IOThread.hpp
- /home/runner/work/openswmm.engine/openswmm.engine/src/engine/output/IOThread.cpp