libxr 1.0
Want to be the best embedded framework
|
ReadPort class for handling read operations. More...
#include <libxr_rw.hpp>
Public Member Functions | |
ReadPort (size_t queue_size=3, size_t buffer_size=128) | |
Constructs a ReadPort with queue sizes. | |
size_t | EmptySize () |
获取队列的剩余可用空间。 Gets the remaining available space in the queue. | |
size_t | Size () |
获取当前队列的已使用大小。 Gets the currently used size of the queue. | |
bool | Readable () |
Checks if read operations are supported. | |
ReadPort & | operator= (ReadFun fun) |
赋值运算符重载,用于设置读取函数。 Overloaded assignment operator to set the read function. | |
void | UpdateStatus (bool in_isr, ErrorCode ans, ReadInfoBlock &info, uint32_t size) |
更新读取操作的状态。 Updates the status of the read operation. | |
void | UpdateStatus (ReadInfoBlock &info) |
标记读取操作为运行中。 Marks the read operation as running. | |
ErrorCode | operator() (RawData data, ReadOperation &op) |
读取操作符重载,用于执行读取操作。 Overloaded function call operator to perform a read operation. | |
void | ProcessPendingReads () |
Processes pending reads. | |
void | Reset () |
Resets the ReadPort. | |
Data Fields | |
ReadFun | read_fun_ = nullptr |
LockFreeQueue< ReadInfoBlock > * | queue_block_ = nullptr |
BaseQueue * | queue_data_ = nullptr |
size_t | read_size_ = 0 |
Mutex | mutex_ |
ReadPort class for handling read operations.
处理读取操作的ReadPort类。
Definition at line 308 of file libxr_rw.hpp.
Constructs a ReadPort with queue sizes.
以指定队列大小构造ReadPort。
queue_size | Number of queued operations. |
buffer_size | Size of each buffer. |
Definition at line 323 of file libxr_rw.hpp.
|
inline |
获取队列的剩余可用空间。 Gets the remaining available space in the queue.
该函数返回 queue_block_
中当前可用的空闲空间大小。 This function returns the size of the available empty space in queue_block_
.
Definition at line 339 of file libxr_rw.hpp.
|
inline |
读取操作符重载,用于执行读取操作。 Overloaded function call operator to perform a read operation.
该函数检查端口是否可读,并根据 data.size_
和 op
的类型执行不同的操作。 This function checks if the port is readable and performs different actions based on data.size_
and the type of op
.
data | 包含要读取的数据。 Contains the data to be read. |
op | 读取操作对象,包含操作类型和同步机制。 Read operation object containing the operation type and synchronization mechanism. |
ErrorCode
,指示操作结果。 Returns an ErrorCode
indicating the result of the operation. Definition at line 427 of file libxr_rw.hpp.
赋值运算符重载,用于设置读取函数。 Overloaded assignment operator to set the read function.
该函数允许使用 ReadFun
类型的函数对象赋值给 ReadPort
,从而设置 read_fun_
。 This function allows assigning a ReadFun
function object to ReadPort
, setting read_fun_
.
fun | 要分配的读取函数。 The read function to be assigned. |
Definition at line 370 of file libxr_rw.hpp.
|
inline |
Processes pending reads.
处理挂起的读取请求。
Definition at line 469 of file libxr_rw.hpp.
|
inline |
Checks if read operations are supported.
检查是否支持读取操作。
Definition at line 355 of file libxr_rw.hpp.
|
inline |
Resets the ReadPort.
重置ReadPort。
Definition at line 490 of file libxr_rw.hpp.
|
inline |
获取当前队列的已使用大小。 Gets the currently used size of the queue.
该函数返回 queue_block_
当前已占用的空间大小。 This function returns the size of the space currently used in queue_block_
.
Definition at line 351 of file libxr_rw.hpp.
|
inline |
更新读取操作的状态。 Updates the status of the read operation.
该函数用于在读取操作过程中更新 read_size_
并调用 UpdateStatus
方法更新 info.op_
的状态。 This function updates read_size_
and calls UpdateStatus
on info.op_
during a read operation.
in_isr | 指示是否在中断上下文中执行。 Indicates whether the operation is executed in an interrupt context. |
ans | 错误码,用于指示操作的结果。 Error code indicating the result of the operation. |
info | 需要更新状态的 ReadInfoBlock 引用。 Reference to the ReadInfoBlock whose status needs to be updated. |
size | 读取的数据大小。 The size of the read data. |
Definition at line 393 of file libxr_rw.hpp.
|
inline |
标记读取操作为运行中。 Marks the read operation as running.
该函数用于将 info.op_
标记为运行状态,以指示当前正在进行读取操作。 This function marks info.op_
as running to indicate an ongoing read operation.
info | 需要更新状态的 ReadInfoBlock 引用。 Reference to the ReadInfoBlock whose status needs to be updated. |
Definition at line 409 of file libxr_rw.hpp.
Mutex LibXR::ReadPort::mutex_ |
Definition at line 315 of file libxr_rw.hpp.
LockFreeQueue<ReadInfoBlock>* LibXR::ReadPort::queue_block_ = nullptr |
Definition at line 312 of file libxr_rw.hpp.
Definition at line 313 of file libxr_rw.hpp.
Definition at line 311 of file libxr_rw.hpp.
size_t LibXR::ReadPort::read_size_ = 0 |
Definition at line 314 of file libxr_rw.hpp.