HDF5FrameWriter Class Reference#
|
DiFfRG
Discretization Framework for functional Renormalization Group flows
|
Writes staged HDF5 frames on a single background thread. More...
#include <hdf5_writer.hh>
Public Member Functions | |
| HDF5FrameWriter (unsigned int queue_depth) | |
| ~HDF5FrameWriter () noexcept | |
| HDF5FrameWriter (const HDF5FrameWriter &)=delete | |
| HDF5FrameWriter & | operator= (const HDF5FrameWriter &)=delete |
| bool | asynchronous () const noexcept |
| void | submit (HDF5Frame frame, FrameTimings *timings=nullptr) |
| Hand a frame over, blocking while the queue is full. | |
| void | drain () |
| void | finish () |
| FrameTimings | worker_totals () const |
Private Member Functions | |
| void | loop () |
| void | rethrow_stored () |
Private Attributes | |
| const unsigned int | depth |
| std::mutex | mutex |
| std::condition_variable | producer_condition |
| std::condition_variable | consumer_condition |
| std::deque< HDF5Frame > | queue |
| bool | stopping = false |
| bool | writing = false |
| a frame has been popped but not finished | |
| bool | finished = false |
| std::exception_ptr | stored_exception |
| FrameTimings | worker_timings |
| std::thread | worker |
Detailed Description
Writes staged HDF5 frames on a single background thread.
One writer serves every HDF5Output of a run. That is a correctness requirement, not a tuning choice: HDF5 here is built without thread safety, so all of its API calls must be serialised, and confining them to one thread is the cheapest way to guarantee that.
Each frame is still opened, written, flushed and closed on its own, so the file stays readable while the run continues and a crash leaves a complete prefix of frames behind. What the thread buys is that the integrator no longer waits for any of it.
Backpressure blocks rather than drops: a producer that outruns the disk waits, and no scientific data is ever discarded.
Constructor & Destructor Documentation
◆ HDF5FrameWriter() [1/2]
|
explicit |
- Parameters
-
queue_depth How many frames may be in flight. 0 runs every frame inline on the calling thread and starts no thread at all – the synchronous behaviour, kept because a hard abort can otherwise lose the frames still queued.
◆ ~HDF5FrameWriter()
|
noexcept |
◆ HDF5FrameWriter() [2/2]
|
delete |
Member Function Documentation
◆ asynchronous()
|
inlinenoexcept |
◆ drain()
| void DiFfRG::HDF5FrameWriter::drain | ( | ) |
Wait for the queue to empty, then rethrow the first worker error, if any.
◆ finish()
| void DiFfRG::HDF5FrameWriter::finish | ( | ) |
Drain and join. Idempotent; safe to call before destruction.
◆ loop()
|
private |
◆ operator=()
|
delete |
◆ rethrow_stored()
|
private |
◆ submit()
| void DiFfRG::HDF5FrameWriter::submit | ( | HDF5Frame | frame, |
| FrameTimings * | timings = nullptr ) |
Hand a frame over, blocking while the queue is full.
Rethrows a stored worker error first, so a failure surfaces on the thread that can act on it. timings is charged the blocking wait only – the write itself is deliberately not charged to the frame, because it no longer sits on the frame's critical path.
◆ worker_totals()
| FrameTimings DiFfRG::HDF5FrameWriter::worker_totals | ( | ) | const |
Work done by the writer thread so far, off the critical path.
Member Data Documentation
◆ consumer_condition
|
private |
◆ depth
|
private |
◆ finished
|
private |
◆ mutex
|
mutableprivate |
◆ producer_condition
|
private |
◆ queue
|
private |
◆ stopping
|
private |
◆ stored_exception
|
private |
◆ worker
|
private |
◆ worker_timings
|
private |
◆ writing
|
private |
a frame has been popped but not finished
The documentation for this class was generated from the following file:
- /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/data/hdf5_writer.hh
Generated by