|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
已提交队头的出队接口 / Consumer interface for one released front. More...
#include <write_port.hpp>
Public Member Functions | |
| WriteQueue (const WriteQueue &)=delete | |
| WriteQueue & | operator= (const WriteQueue &)=delete |
| WriteQueue (WriteQueue &&)=delete | |
| WriteQueue & | operator= (WriteQueue &&)=delete |
| ~WriteQueue () noexcept | |
| 结算出队,使用获取时的上下文 / Settle progress using the captured context. | |
| size_t | AvailableSize () const |
| 获取当前队头的剩余长度 / Get the current front remainder. | |
| bool | Empty () const |
| 检查本接口是否还有数据 / Check whether this interface has remaining data. | |
| void | PopAll (uint8_t *destination) |
| 复制并取走队头剩余数据 / Copy and consume the entire front remainder. | |
| template<typename Writer > | |
| size_t | PopWithWriter (size_t limit, Writer &&writer) |
| 通过回调取走队头前缀 / Consume a front prefix through a callback. | |
| void | FailFront (ErrorCode reason) |
| 丢弃剩余数据并结束队头 / Discard the remainder and fail the front. | |
Friends | |
| class | WritePort |
已提交队头的出队接口 / Consumer interface for one released front.
每个对象只对应一个请求的剩余部分,最多调用一次 PopAll、PopWithWriter 或 FailFront。 析构时记录本次进展;整个请求结束后才移除请求并发送完成通知。继续处理须重新获取接口。 Each object covers one request remainder and permits at most one PopAll, PopWithWriter, or FailFront call. Destruction accounts progress and retires and completes the request only when its entire remainder is consumed. Obtain a new interface for further progress.
Definition at line 153 of file write_port.hpp.
|
noexcept |
结算出队,使用获取时的上下文 / Settle progress using the captured context.
Definition at line 196 of file write_port.cpp.
|
inlinenodiscard |
获取当前队头的剩余长度 / Get the current front remainder.
Definition at line 167 of file write_port.hpp.
|
inlinenodiscard |
检查本接口是否还有数据 / Check whether this interface has remaining data.
Definition at line 178 of file write_port.hpp.
| void WritePort::WriteQueue::FailFront | ( | ErrorCode | reason | ) |
丢弃剩余数据并结束队头 / Discard the remainder and fail the front.
| reason | 请求的完成错误,不可为 OK / Completion error, which must not be OK. |
Definition at line 174 of file write_port.cpp.
| void WritePort::WriteQueue::PopAll | ( | uint8_t * | destination | ) |
复制并取走队头剩余数据 / Copy and consume the entire front remainder.
| destination | 后端接收地址,至少容纳 AvailableSize() 字节。 Backend destination with room for at least AvailableSize() bytes. |
Definition at line 145 of file write_port.cpp.
|
inline |
通过回调取走队头前缀 / Consume a front prefix through a callback.
| Writer | 后端接收函数类型 / Backend writer callback type. |
| limit | 本次最多提供的字节数 / Maximum number of bytes to offer. |
| writer | 签名为 size_t(const uint8_t*, size_t, const uint8_t*, size_t), 接收按 FIFO 顺序排列的最多两段数据,返回已接收的连续前缀长度。 Callable as size_t(const uint8_t*, size_t, const uint8_t*, size_t); receives up to two FIFO-ordered spans and returns the accepted prefix length. |
Definition at line 214 of file write_port.hpp.
|
friend |
Definition at line 249 of file write_port.hpp.