#include <poll_handler.h>
◆ PollHandler()
apollo::cyber::io::PollHandler::PollHandler |
( |
int |
fd | ) |
|
|
explicit |
在文件 poll_handler.cc 第 30 行定义.
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.cc 第 33 行定义.
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}
◆ fd()
int apollo::cyber::io::PollHandler::fd |
( |
| ) |
const |
|
inline |
◆ set_fd()
void apollo::cyber::io::PollHandler::set_fd |
( |
int |
fd | ) |
|
|
inline |
◆ Unblock()
bool apollo::cyber::io::PollHandler::Unblock |
( |
| ) |
|
在文件 poll_handler.cc 第 61 行定义.
61 {
62 is_blocking_.store(false);
63 return Poller::Instance()->Unregister(request_);
64}
该类的文档由以下文件生成: