6#include "double_buffer.hpp"
8#include "libxr_assert.hpp"
9#include "operation.hpp"
双缓冲区管理类 / Double buffer manager class
void Reset()
重置 active/pending 状态,但保留已绑定的 backing storage Resets active/pending state while keeping bound backing ...
void FlipActiveBlock()
翻转当前活动缓冲区编号 Flips the current active block index
size_t Size() const
获取每个缓冲区的大小(单位:字节) Gets the size of each buffer in bytes
uint8_t * ActiveBuffer() const
获取当前正在使用的缓冲区指针 Returns the currently active buffer
void Init(const LibXR::RawData &raw_data)
绑定连续 backing storage 并重置双缓冲状态 Binds continuous backing storage and resets double-buffer state
uint8_t * PendingBuffer() const
获取备用缓冲区的指针 Returns the pending (inactive) buffer
void Reset()
重置当前 active/pending 发送状态。
void LoadActive(size_t size, const WriteInfoBlock &info)
装载一个 active 请求的长度与元数据。
size_t ActiveOffset() const
获取当前 active payload 已推进的偏移量。
size_t active_length_
active payload 长度。 Active payload length.
const WriteInfoBlock & PendingInfo() const
获取 pending 请求元数据常量引用。
void LoadPending(size_t size, const WriteInfoBlock &info)
装载一个 pending 请求的长度与元数据。
void ClearActive()
清除当前 active 请求状态。
void Init(RawData storage)
绑定外部双缓冲 backing storage 并重置状态。
bool HasActive() const
判断是否存在有效 active 请求。
WriteInfoBlock pending_info_
pending 请求元数据。 Pending request metadata.
Flag::Atomic pending_valid_
pending 请求是否有效。 Whether a pending request is valid.
const WriteInfoBlock & ActiveInfo() const
获取 active 请求元数据常量引用。
WriteInfoBlock active_info_
active 请求元数据。 Active request metadata.
size_t active_offset_
active payload 已推进偏移。 Active progressed offset.
size_t pending_length_
pending payload 长度。 Pending payload length.
bool PromotePending()
将 pending 请求提升为 active 请求。
void SetActiveOffset(size_t offset)
更新当前 active payload 已推进的偏移量。
uint8_t * PendingBuffer() const
获取当前 pending payload 缓冲区指针。
WriteInfoBlock & PendingInfo()
获取 pending 请求元数据引用。
bool HasPending() const
判断是否存在有效 pending 请求。
DoubleBuffer bytes_
payload 双缓冲对象。 Payload double-buffer object.
bool active_valid_
active 请求是否有效。 Whether an active request is valid.
ESPTxDoubleBuffer()=default
默认构造辅助器。
uint8_t * ActiveBuffer() const
获取当前 active payload 缓冲区指针。
WriteInfoBlock & ActiveInfo()
获取 active 请求元数据引用。
size_t ActiveLength() const
获取当前 active payload 长度。
void ClearPending()
清除当前 pending 请求状态。
size_t BufferSize() const
获取单个半缓冲区大小。
void Set() noexcept
置位标志 / Set the flag
bool TestAndClear() noexcept
测试并清除:清除并返回旧状态 / Test-and-clear: clear and return previous state
bool IsSet() const noexcept
判断是否已置位 / Check whether the flag is set
void Clear() noexcept
清除标志 / Clear the flag
可写原始数据视图 / Mutable raw data view