Apollo 10.0
自动驾驶开放平台
apollo::cyber::io::PollHandler类 参考

#include <poll_handler.h>

apollo::cyber::io::PollHandler 的协作图:

Public 成员函数

 PollHandler (int fd)
 
virtual ~PollHandler ()=default
 
bool Block (int timeout_ms, bool is_read)
 
bool Unblock ()
 
int fd () const
 
void set_fd (int fd)
 

详细描述

在文件 poll_handler.h30 行定义.

构造及析构函数说明

◆ PollHandler()

apollo::cyber::io::PollHandler::PollHandler ( int  fd)
explicit

在文件 poll_handler.cc30 行定义.

31 : fd_(fd), is_read_(false), is_blocking_(false), routine_(nullptr) {}

◆ ~PollHandler()

virtual apollo::cyber::io::PollHandler::~PollHandler ( )
virtualdefault

成员函数说明

◆ Block()

bool apollo::cyber::io::PollHandler::Block ( int  timeout_ms,
bool  is_read 
)

在文件 poll_handler.cc33 行定义.

33 {
34 if (!Check(timeout_ms)) {
35 return false;
36 }
37
38 if (is_blocking_.exchange(true)) {
39 AINFO << "poll handler is blocking.";
40 return false;
41 }
42
43 Fill(timeout_ms, is_read);
44 if (!Poller::Instance()->Register(request_)) {
45 is_blocking_.store(false);
46 return false;
47 }
48
49 routine_->Yield(RoutineState::IO_WAIT);
50
51 bool result = false;
52 uint32_t target_events = is_read ? EPOLLIN : EPOLLOUT;
53 if (response_.events & target_events) {
54 result = true;
55 }
56 is_blocking_.store(false);
57
58 return result;
59}
#define AINFO
Definition log.h:42

◆ fd()

int apollo::cyber::io::PollHandler::fd ( ) const
inline

在文件 poll_handler.h38 行定义.

38{ return fd_; }

◆ set_fd()

void apollo::cyber::io::PollHandler::set_fd ( int  fd)
inline

在文件 poll_handler.h39 行定义.

39{ fd_ = fd; }

◆ Unblock()

bool apollo::cyber::io::PollHandler::Unblock ( )

在文件 poll_handler.cc61 行定义.

61 {
62 is_blocking_.store(false);
63 return Poller::Instance()->Unregister(request_);
64}

该类的文档由以下文件生成: