20#ifndef CPPNET_ASYNC_CONTEXT_HPP
21#define CPPNET_ASYNC_CONTEXT_HPP
22#include "net/detail/immovable.hpp"
23#include "net/timers/timers.hpp"
25#include <exec/async_scope.hpp>
40 using triggers = io::execution::basic_triggers<multiplexer_type>;
52 using clock = std::chrono::steady_clock;
57 enum signals : std::uint8_t { terminate = 0, user1, END };
70 std::atomic<context_states>
state{PENDING};
77 inline auto signal(
int signum) -> void;
104 template <typename Fn>
105 requires std::is_invocable_r_v<
bool, Fn>
109 inline auto
run() ->
void;
114#include "impl/async_context_impl.hpp"
This namespace is for network services.
Definition async_context.hpp:31
An asynchronous execution context.
Definition async_context.hpp:34
std::chrono::milliseconds duration
The duration type.
Definition async_context.hpp:54
io::execution::basic_triggers< multiplexer_type > triggers
The io triggers type.
Definition async_context.hpp:40
triggers poller
The poll triggers.
Definition async_context.hpp:66
io::execution::poll_multiplexer multiplexer_type
The io multiplexer type.
Definition async_context.hpp:38
triggers::socket_dialog socket_dialog
The socket dialog type.
Definition async_context.hpp:42
std::chrono::steady_clock clock
The clock type.
Definition async_context.hpp:52
exec::async_scope async_scope
Asynchronous scope type.
Definition async_context.hpp:36
timers_type timers
The event loop timers.
Definition async_context.hpp:62
context_states
An enum of valid context states.
Definition async_context.hpp:59
auto isr(const socket_dialog &socket, Fn routine) -> void
An interrupt service routine for the poller.
io::socket::native_socket_type socket_type
The socket type.
Definition async_context.hpp:44
signals
An enum of all valid async context signals.
Definition async_context.hpp:57
auto run() -> void
Runs the event loop.
std::atomic< context_states > state
A counter that tracks the context state.
Definition async_context.hpp:70
auto interrupt() const noexcept -> void
Calls the timers interrupt.
async_scope scope
The asynchronous scope.
Definition async_context.hpp:64
std::atomic< signal_mask > sigmask
The active signal mask.
Definition async_context.hpp:68
std::uint64_t signal_mask
The signal mask type.
Definition async_context.hpp:46
auto signal(int signum) -> void
Sets the signal mask, then interrupts the service.
A socketpair interrupt source.
Definition interrupt.hpp:27