24#include <seastar/core/future.hh>
26#include <seastar/util/bool_class.hh>
27#include <seastar/util/modules.hh>
29#include <boost/intrusive_ptr.hpp>
38SEASTAR_MODULE_EXPORT_BEGIN
41class pollable_fd_state;
43SEASTAR_MODULE_EXPORT_END
47class buffer_allocator;
60using pollable_fd_state_ptr = boost::intrusive_ptr<pollable_fd_state>;
67 explicit speculation(
int epoll_events_guessed = 0) : events(epoll_events_guessed) {}
85 if (events_known & events) {
86 events_known &= ~events;
92 bool events_rw =
false;
93 unsigned shutdown_mask = 0;
94 int events_requested = 0;
100 friend class reactor_backend_uring;
106 future<> write_all(
const char* buffer,
size_t size);
107 future<> write_all(
const uint8_t* buffer,
size_t size);
123 : fd(
std::move(fd)), events_known(speculate.events) {}
124 ~pollable_fd_state() =
default;
126 void maybe_no_more_recv();
127 void maybe_no_more_send();
130 friend void intrusive_ptr_add_ref(pollable_fd_state* fd) {
133 friend void intrusive_ptr_release(pollable_fd_state* fd);
143 return _s->read_some(buffer, size);
146 return _s->read_some(buffer, size);
149 return _s->read_some(iov);
152 return _s->read_some(ba);
154 future<> write_all(
const char* buffer,
size_t size) {
155 return _s->write_all(buffer, size);
157 future<> write_all(
const uint8_t* buffer,
size_t size) {
158 return _s->write_all(buffer, size);
161 return _s->write_some(p);
164 return _s->write_all(p);
167 return _s->readable();
170 return _s->writeable();
173 return _s->readable_or_writeable();
179 return _s->connect(sa);
182 return _s->recv_some(ba);
185 return _s->sendmsg(msg);
188 return _s->recvmsg(msg);
191 return _s->sendto(addr, buf, len);
193 file_desc& get_file_desc()
const {
return _s->fd; }
196 void close() { _s.reset(); }
197 explicit operator bool()
const noexcept {
201 return _s->poll_rdhup();
204 int get_fd()
const {
return _s->fd.get(); }
205 void maybe_no_more_recv() {
return _s->maybe_no_more_recv(); }
206 void maybe_no_more_send() {
return _s->maybe_no_more_send(); }
210 friend class aio_storage_context;
212 pollable_fd_state_ptr _s;
220 explicit readable_eventfd(
size_t initial = 0) : _fd(try_create_eventfd(initial)) {}
224 int get_write_fd() {
return _fd.get_fd(); }
227 static file_desc try_create_eventfd(
size_t initial);
235 explicit writeable_eventfd(
size_t initial = 0) : _fd(try_create_eventfd(initial)) {}
238 void signal(
size_t nr);
239 int get_read_fd() {
return _fd.get(); }
242 static file_desc try_create_eventfd(
size_t initial);
Type-safe boolean.
Definition: bool_class.hh:58
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
Definition: pollable_fd.hh:62
bool take_speculation(int events)
Definition: pollable_fd.hh:83
void speculate_epoll(int events)
Definition: pollable_fd.hh:78
Definition: pollable_fd.hh:136
Definition: reactor.hh:146
Definition: pollable_fd.hh:217
Definition: socket_defs.hh:47
Definition: pollable_fd.hh:232
future< connected_socket > connect(socket_address sa)
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: pollable_fd.hh:65