|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
合并多次写入的流接口 / Stream interface for batched writes. More...
#include <write_port.hpp>
Public Member Functions | |
| Stream (WritePort *port, WriteOperation op) | |
| 构造流并尝试取得写入权 / Construct a stream and try to acquire the port. | |
| ~Stream () | |
| 提交剩余批次并结束流 / Submit the remaining batch and destroy the stream. | |
| Stream (const Stream &)=delete | |
| Stream & | operator= (const Stream &)=delete |
| Stream (Stream &&)=delete | |
| Stream & | operator= (Stream &&)=delete |
| ErrorCode | Write (ConstRawData data) |
| 向当前批次追加数据 / Append data to the current batch. | |
| ErrorCode | Write (std::string_view text) |
| 向当前批次追加文本 / Append text to the current batch. | |
| Stream & | operator<< (const ConstRawData &data) |
| 尝试追加数据并返回流引用 / Try to append data and return the stream. | |
| ErrorCode | Commit () |
| 提交批次并释放写入权 / Submit the batch and release producer access. | |
| ErrorCode | Acquire () |
| 尝试取得端口写入权 / Try to acquire the port's producer access. | |
| size_t | EmptySize () const |
| 获取当前批次可追加的空间 / Get current free space for appending. | |
合并多次写入的流接口 / Stream interface for batched writes.
取得写入权后,各次 Write 直接复制到端口队列;Commit 或析构提交整个批次。 普通后端在提交后才可消费本批次,Pipe 读端可在提交前读到已追加的字节。 Once acquired, each Write copies into the port queue. Commit or destruction submits the batch. Queued backends consume it only after submission; Pipe readers may consume appended bytes before submission.
Definition at line 294 of file write_port.hpp.
| WritePort::Stream::Stream | ( | WritePort * | port, |
| WriteOperation | op ) |
构造流并尝试取得写入权 / Construct a stream and try to acquire the port.
| port | 目标写端口 / Target write port. |
| op | 每个批次使用的完成通知描述符 / Completion descriptor used for each batch. |
Definition at line 5 of file write_stream.cpp.
| WritePort::Stream::~Stream | ( | ) |
提交剩余批次并结束流 / Submit the remaining batch and destroy the stream.
Definition at line 10 of file write_stream.cpp.
|
nodiscard |
尝试取得端口写入权 / Try to acquire the port's producer access.
Definition at line 27 of file write_stream.cpp.
|
nodiscard |
提交批次并释放写入权 / Submit the batch and release producer access.
Definition at line 128 of file write_stream.cpp.
|
inlinenodiscard |
获取当前批次可追加的空间 / Get current free space for appending.
Definition at line 391 of file write_port.hpp.
| WritePort::Stream & WritePort::Stream::operator<< | ( | const ConstRawData & | data | ) |
尝试追加数据并返回流引用 / Try to append data and return the stream.
| data | 待追加的数据 / Data to append. |
Definition at line 119 of file write_stream.cpp.
|
nodiscard |
向当前批次追加数据 / Append data to the current batch.
| data | 数据源和字节数;正长度时地址须有效,返回后即可复用源缓冲区。 Source and byte count; a positive size requires a valid address. The source buffer may be reused after return. |
Definition at line 56 of file write_stream.cpp.
|
inlinenodiscard |
向当前批次追加文本 / Append text to the current batch.
| text | 待复制的文本,不附加结束符 / Text to copy without an added terminator. |
Definition at line 340 of file write_port.hpp.