|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
File writer with a pool of page-aligned buffers and a writer thread: writeEvent() fills buffers and queues full ones, and the thread writes them to the file. More...
#include <FileWriter.hh>
Inherits Drp::FileWriterBase.
Public Member Functions | |
| BufferedFileWriterMT (size_t bufferSize) | |
| Create 64 buffers of bufferSize bytes rounded up to whole pages and start the writer thread. | |
| BufferedFileWriterMT (size_t bufferSize, bool dio) | |
| Like BufferedFileWriterMT(bufferSize). | |
| ~BufferedFileWriterMT () override | |
| Close the file, stop and join the writer thread, and free the buffers in the free queue. | |
| int | open (const std::string &fileName) override |
| Like BufferedFileWriter::open(), adding O_DIRECT when direct I/O was requested. | |
| int | close () override |
| If a file is open, call flush() (which waits until all queued buffers are written) and close the file. | |
| void | flush () |
| Queue the current buffer if it holds data, then block until the writer thread has written everything queued. | |
| void | writeEvent (const void *data, size_t size, XtcData::TimeStamp ts) override |
| Copy size bytes from data into the current free buffer, first queueing that buffer if data does not fit or the batch is more than 2 s old; a datagram larger than the free space is split across buffers. | |
| void | run () |
| Writer thread body started by the constructor: name the thread drp/FileWriter, write each queued buffer to the file and return it to the free queue, until terminated with nothing queued. | |
| uint64_t | depth () const |
| Return the number of free buffers recorded at the last queue operation. | |
| uint64_t | size () const |
| Return the number of buffers in the pool. | |
| uint64_t | freeBlocked () const |
| Return the counter that is raised while writeEvent() waits for a free buffer. | |
| uint64_t | pendBlocked () const |
| Return the counter that is raised while flush() or the writer thread waits on the pending queue. | |
Public Member Functions inherited from Drp::FileWriterBase | |
| FileWriterBase () | |
| Start with the writing counter at 0. | |
| virtual | ~FileWriterBase () |
| Does nothing; empty body. | |
| virtual uint64_t | writing () const |
| Return the writing counter (non-zero while an implementation is inside a write). | |
Additional Inherited Members | |
Protected Attributes inherited from Drp::FileWriterBase | |
| volatile uint64_t | m_writing |
File writer with a pool of page-aligned buffers and a writer thread: writeEvent() fills buffers and queues full ones, and the thread writes them to the file.
| Drp::BufferedFileWriterMT::BufferedFileWriterMT | ( | size_t | bufferSize | ) |
Create 64 buffers of bufferSize bytes rounded up to whole pages and start the writer thread.
| Drp::BufferedFileWriterMT::BufferedFileWriterMT | ( | size_t | bufferSize, |
| bool | dio | ||
| ) |
Like BufferedFileWriterMT(bufferSize).
With dio true there are 2 buffers, each the smallest multiple of bufferSize that is at least 512 MiB (then rounded up to whole pages), and files are opened with O_DIRECT.
|
override |
Close the file, stop and join the writer thread, and free the buffers in the free queue.
|
overridevirtual |
If a file is open, call flush() (which waits until all queued buffers are written) and close the file.
Returns the close() result, or 0 if no file was open.
Implements Drp::FileWriterBase.
|
inline |
Return the number of free buffers recorded at the last queue operation.
| void Drp::BufferedFileWriterMT::flush | ( | ) |
Queue the current buffer if it holds data, then block until the writer thread has written everything queued.
|
inline |
Return the counter that is raised while writeEvent() waits for a free buffer.
|
overridevirtual |
Like BufferedFileWriter::open(), adding O_DIRECT when direct I/O was requested.
Implements Drp::FileWriterBase.
|
inline |
Return the counter that is raised while flush() or the writer thread waits on the pending queue.
| void Drp::BufferedFileWriterMT::run | ( | ) |
Writer thread body started by the constructor: name the thread drp/FileWriter, write each queued buffer to the file and return it to the free queue, until terminated with nothing queued.
Aborts if a write fails.
|
inline |
Return the number of buffers in the pool.
|
overridevirtual |
Copy size bytes from data into the current free buffer, first queueing that buffer if data does not fit or the batch is more than 2 s old; a datagram larger than the free space is split across buffers.
Blocks while no free buffer is available.
Implements Drp::FileWriterBase.