24 #include <seastar/core/future.hh>
26 #include <seastar/core/internal/io_desc.hh>
27 #include <seastar/util/bool_class.hh>
28 #include <seastar/util/modules.hh>
29 #ifndef SEASTAR_MODULE
30 #include <boost/intrusive_ptr.hpp>
39 SEASTAR_MODULE_EXPORT_BEGIN
42 class pollable_fd_state;
44 SEASTAR_MODULE_EXPORT_END
48 class buffer_allocator;
61 using pollable_fd_state_ptr = boost::intrusive_ptr<pollable_fd_state>;
69 explicit speculation(
int epoll_events_guessed = 0) : events(epoll_events_guessed) {}
87 if (events_known & events) {
88 events_known &= ~events;
94 bool events_rw =
false;
95 unsigned shutdown_mask = 0;
96 int events_requested = 0;
102 friend class reactor_backend_uring;
108 future<> write_all(
const char* buffer,
size_t size);
109 future<> write_all(
const uint8_t* buffer,
size_t size);
125 : fd(std::move(fd)), events_known(speculate.events) {}
127 void maybe_no_more_recv();
128 void maybe_no_more_send();
131 friend void intrusive_ptr_add_ref(pollable_fd_state* fd) {
134 friend void intrusive_ptr_release(pollable_fd_state* fd);
144 return _s->read_some(buffer, size);
147 return _s->read_some(buffer, size);
150 return _s->read_some(iov);
153 return _s->read_some(ba);
155 future<> write_all(
const char* buffer,
size_t size) {
156 return _s->write_all(buffer, size);
158 future<> write_all(
const uint8_t* buffer,
size_t size) {
159 return _s->write_all(buffer, size);
162 return _s->write_some(p);
165 return _s->write_all(p);
168 return _s->readable();
171 return _s->writeable();
174 return _s->readable_or_writeable();
180 return _s->connect(sa);
183 return _s->recv_some(ba);
186 return _s->sendmsg(msg);
189 return _s->recvmsg(msg);
192 return _s->sendto(addr, buf, len);
194 file_desc& get_file_desc()
const {
return _s->fd; }
197 void close() { _s.reset(); }
198 explicit operator bool()
const noexcept {
202 return _s->poll_rdhup();
205 int get_fd()
const {
return _s->fd.get(); }
206 void maybe_no_more_recv() {
return _s->maybe_no_more_recv(); }
207 void maybe_no_more_send() {
return _s->maybe_no_more_send(); }
211 friend class aio_storage_context;
213 pollable_fd_state_ptr _s;
221 explicit readable_eventfd(
size_t initial = 0) : _fd(try_create_eventfd(initial)) {}
225 int get_write_fd() {
return _fd.get_fd(); }
228 static file_desc try_create_eventfd(
size_t initial);
236 explicit writeable_eventfd(
size_t initial = 0) : _fd(try_create_eventfd(initial)) {}
239 void signal(
size_t nr);
240 int get_read_fd() {
return _fd.get(); }
243 static file_desc try_create_eventfd(
size_t initial);
Type-safe boolean.
Definition: bool_class.hh:57
A representation of a possibly not-yet-computed value.
Definition: future.hh:1238
Definition: pollable_fd.hh:63
bool take_speculation(int events)
Definition: pollable_fd.hh:85
void speculate_epoll(int events)
Definition: pollable_fd.hh:80
Definition: pollable_fd.hh:137
Definition: reactor.hh:168
Definition: pollable_fd.hh:218
Definition: socket_defs.hh:47
Definition: pollable_fd.hh:233
future< connected_socket > connect(socket_address sa)
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: pollable_fd.hh:67