1#include "read_port.hpp"
36 if (info.
op.
type == ReadOperation::OperationType::BLOCK)
71 if (readable_size >= data.
size_ && readable_size != 0)
81 if (op.
type != ReadOperation::OperationType::BLOCK)
94 std::memory_order_acq_rel,
95 std::memory_order_acquire))
102 if (
static_cast<int8_t
>(ans) >= 0)
112 std::memory_order_acq_rel,
113 std::memory_order_acquire))
115 if (op.
type != ReadOperation::OperationType::BLOCK)
131 ASSERT(op.
type != ReadOperation::OperationType::BLOCK);
138 if (op.
type == ReadOperation::OperationType::BLOCK)
141 auto wait_ans = op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
146#ifdef LIBXR_DEBUG_BUILD
147 auto state =
busy_.load(std::memory_order_acquire);
159 std::memory_order_acq_rel,
160 std::memory_order_acquire))
177 auto finish_wait_ans = op.
data.sem_info.sem->
Wait(UINT32_MAX);
178 UNUSED(finish_wait_ans);
200 auto is_busy =
busy_.load(std::memory_order_acquire);
207 if (
info_.
op.
type == ReadOperation::OperationType::BLOCK)
213 std::memory_order_acq_rel,
214 std::memory_order_acquire))
245 std::memory_order_acq_rel,
246 std::memory_order_acquire))
263 auto state =
busy_.load(std::memory_order_acquire);
271 std::memory_order_acq_rel,
272 std::memory_order_acquire))
282 if (queued_size == 0)
303 std::memory_order_release);
312 auto state =
busy_.load(std::memory_order_acquire);
325 DEV_ASSERT_FROM_CALLBACK(
false, in_isr);
333 if (
info_.
op.
type == ReadOperation::OperationType::BLOCK)
341 std::memory_order_acq_rel,
342 std::memory_order_acquire))
union LibXR::Operation::@5 data
void UpdateStatus(bool in_isr, Status &&status)
Updates operation status based on type.
void MarkAsRunning()
标记操作为运行状态。 Marks the operation as running.
可写原始数据视图 / Mutable raw data view
size_t size_
数据字节数 / Data size in bytes
void * addr_
数据起始地址 / Data start address
ReadPort class for handling read operations.
bool Readable()
Checks if read operations are supported.
ReadFun read_fun_
Driver/backend read notification entry. 底层驱动或后端读取通知入口。
void Finish(bool in_isr, ErrorCode ans, ReadInfoBlock &info)
完成已由队列路径认领的读取操作。 Completes a read operation already claimed by the queue path.
ReadPort(size_t buffer_size=128)
Constructs a ReadPort with queue sizes.
ErrorCode ClearQueuedData(bool in_isr=false)
清空当前已排队的 RX 字节。
ErrorCode block_result_
Final status for the current BLOCK read.
@ IDLE
No active waiter and no pending completion. 无等待者、无挂起完成。
std::atomic< BusyState > busy_
Shared read-progress handoff state. 共享的读进度交接状态。
size_t EmptySize()
获取队列的剩余可用空间。 Gets the remaining available space in the queue.
ErrorCode operator()(RawData data, ReadOperation &op, bool in_isr=false)
读取操作符重载,用于执行读取操作。 Overloaded function call operator to perform a read operation.
SPSCQueue< uint8_t > * queue_data_
RX payload queue. 接收数据字节队列。
void ProcessPendingReads(bool in_isr)
Processes pending reads.
ReadPort & operator=(ReadFun fun)
赋值运算符重载,用于设置读取函数。 Overloaded assignment operator to set the read function.
size_t Size()
获取当前队列的已使用大小。 Gets the currently used size of the queue.
void FailAndClearAll(ErrorCode reason, bool in_isr)
失败完成并清空当前所有挂起读操作。
virtual void OnRxDequeue(bool)
RX 数据从软件队列成功出队后的通知。 Notification after bytes are popped from RX data queue.
ReadInfoBlock info_
In-flight read request metadata. 当前在途读取请求的元数据。
void MarkAsRunning(ReadInfoBlock &info)
标记读取操作为运行中。 Marks the read operation as running.
size_t Size() const
获取当前已用元素数 / Get the current element count
size_t EmptySize() const
获取剩余空槽数 / Get the current free-slot count
ErrorCode PopBatch(Data *data, size_t size)
批量弹出多个 payload。
void PostFromCallback(bool in_isr)
从中断回调中释放(增加)信号量 Releases (increments) the semaphore from an ISR (Interrupt Service Routine)
ErrorCode Wait(uint32_t timeout=UINT32_MAX)
等待(减少)信号量 Waits (decrements) the semaphore
@ NOT_SUPPORT
不支持 | Not supported
@ OK
操作成功 | Operation successful
ErrorCode(* ReadFun)(ReadPort &port, bool in_isr)
Function pointer type for read notifications.
constexpr size_t CONCURRENCY_ALIGNMENT
并发结构对齐粒度(用于降低多核伪共享) / Alignment policy used by concurrency-oriented structures
Read information block structure.
RawData data
Data buffer. 数据缓冲区。
ReadOperation op
Read operation instance. 读取操作实例。