|
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
|
Single-threaded event loop with a timer min-heap and a thread-safe mailbox (post/wake via eventfd), over one of two backends chosen at construction: More...
#include "fastmm/net/inplace_callback.hpp"#include <atomic>#include <cstddef>#include <cstdint>#include <functional>#include <memory>#include <mutex>#include <string_view>#include <vector>Go to the source code of this file.
Classes | |
| class | fastmm::net::IoHandler |
| class | fastmm::net::Reactor |
Namespaces | |
| namespace | fastmm |
| namespace | fastmm::net |
Typedefs | |
| using | fastmm::net::TimerId = std::uint64_t |
Enumerations | |
| enum class | fastmm::net::IoEvent : std::uint32_t { fastmm::net::None = 0 , fastmm::net::Read = 1 , fastmm::net::Write = 2 , fastmm::net::ReadWrite = 3 } |
| enum class | fastmm::net::ReactorBackend : std::uint8_t { fastmm::net::Epoll , fastmm::net::IoUring } |
Functions | |
| constexpr IoEvent | fastmm::net::operator| (IoEvent a, IoEvent b) noexcept |
| constexpr bool | fastmm::net::has (IoEvent set, IoEvent flag) noexcept |
| std::string_view | fastmm::net::to_string (ReactorBackend backend) noexcept |
| "epoll" / "io_uring", the spelling of [engine] net_backend. | |
| bool | fastmm::net::parse_reactor_backend (std::string_view text, ReactorBackend &out) noexcept |
Parses "epoll" / "io_uring". Returns false (and leaves out alone) for anything else. | |
Variables | |
| constexpr TimerId | fastmm::net::kInvalidTimer = 0 |
Single-threaded event loop with a timer min-heap and a thread-safe mailbox (post/wake via eventfd), over one of two backends chosen at construction:
ReactorBackend::Epoll edge-triggered epoll (the default) ReactorBackend::IoUring io_uring, one multishot IORING_OP_POLL_ADD per registered fd, timeouts through IORING_ENTER_EXT_ARG, over liburing
All handler callbacks and timers run on the thread that calls run()/run_once(); only wake() and post() may be called from other threads.
Handler contract (both backends): a handler receiving on_readable()/on_writable() must drain the fd until it returns want_read/want_write, otherwise no further event may be delivered. The io_uring backend may report readiness the handler has already consumed; draining until EAGAIN makes that harmless. POLLOUT is only requested while the registration asks for Write.
Descriptor lifetime: call remove() before closing a registered fd. epoll forgets a closed descriptor on its own, but an io_uring poll request holds a reference to the file, so the socket stays open (no FIN, port still bound) until remove() cancels the request. add() of a new socket that reuses the number of a closed but still registered fd cancels the stale registration; this cannot be detected for anonymous-inode descriptors (eventfd, timerfd).