Apollo
10.0
自动驾驶开放平台
poll_handler.h
浏览该文件的文档.
1
/******************************************************************************
2
* Copyright 2018 The Apollo Authors. All Rights Reserved.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*****************************************************************************/
16
17
#ifndef CYBER_IO_POLL_HANDLER_H_
18
#define CYBER_IO_POLL_HANDLER_H_
19
20
#include <atomic>
21
#include <memory>
22
23
#include "
cyber/croutine/croutine.h
"
24
#include "
cyber/io/poll_data.h
"
25
26
namespace
apollo
{
27
namespace
cyber {
28
namespace
io {
29
30
class
PollHandler
{
31
public
:
32
explicit
PollHandler
(
int
fd
);
33
virtual
~PollHandler
() =
default
;
34
35
bool
Block
(
int
timeout_ms,
bool
is_read);
36
bool
Unblock
();
37
38
int
fd
()
const
{
return
fd_; }
39
void
set_fd
(
int
fd
) { fd_ =
fd
; }
40
41
private
:
42
bool
Check(
int
timeout_ms);
43
void
Fill(
int
timeout_ms,
bool
is_read);
44
void
ResponseCallback(
const
PollResponse
& rsp);
45
46
int
fd_;
47
PollRequest
request_;
48
PollResponse
response_;
49
std::atomic<bool> is_read_;
50
std::atomic<bool> is_blocking_;
51
croutine::CRoutine
* routine_;
52
};
53
54
}
// namespace io
55
}
// namespace cyber
56
}
// namespace apollo
57
58
#endif
// CYBER_IO_POLL_HANDLER_H_
apollo::cyber::croutine::CRoutine
Definition
croutine.h:40
apollo::cyber::io::PollHandler
Definition
poll_handler.h:30
apollo::cyber::io::PollHandler::set_fd
void set_fd(int fd)
Definition
poll_handler.h:39
apollo::cyber::io::PollHandler::~PollHandler
virtual ~PollHandler()=default
apollo::cyber::io::PollHandler::fd
int fd() const
Definition
poll_handler.h:38
apollo::cyber::io::PollHandler::Unblock
bool Unblock()
Definition
poll_handler.cc:61
apollo::cyber::io::PollHandler::Block
bool Block(int timeout_ms, bool is_read)
Definition
poll_handler.cc:33
croutine.h
apollo
class register implement
Definition
arena_queue.h:37
poll_data.h
apollo::cyber::io::PollRequest
Definition
poll_data.h:35
apollo::cyber::io::PollResponse
Definition
poll_data.h:29
cyber
io
poll_handler.h