cppnet
C++ network utilities for asynchronous servers.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
net::service::basic_context_thread< Service > Class Template Reference

A threaded asynchronous service. More...

#include <net/service/context_thread.hpp>

Inheritance diagram for net::service::basic_context_thread< Service >:
net::service::async_context

Public Member Functions

 basic_context_thread ()=default
 Default constructor.
 
 basic_context_thread (const basic_context_thread &)=delete
 Deleted copy constructor.
 
 basic_context_thread (basic_context_thread &&)=delete
 Deleted move constructor.
 
auto operator= (const basic_context_thread &) -> basic_context_thread &=delete
 Deleted copy assignment.
 
auto operator= (basic_context_thread &&) -> basic_context_thread &=delete
 Deleted move assignment.
 
template<typename... Args>
auto start (Args &&...args) -> void
 Start the asynchronous service.
 
 ~basic_context_thread ()
 The destructor signals the thread before joining it.
 
- Public Member Functions inherited from net::service::async_context
auto signal (int signum) -> void
 Sets the signal mask, then interrupts the service.
 
auto interrupt () const noexcept -> void
 Calls the timers interrupt.
 
template<typename Fn >
requires std::is_invocable_r_v<bool, Fn>
auto isr (const socket_dialog &socket, Fn routine) -> void
 An interrupt service routine for the poller.
 
auto run () -> void
 Runs the event loop.
 

Additional Inherited Members

- Public Types inherited from net::service::async_context
enum  signals : std::uint8_t { terminate = 0 , user1 , END }
 An enum of all valid async context signals.
 
enum  context_states : std::uint8_t { PENDING = 0 , STARTED , STOPPED }
 An enum of valid context states.
 
using async_scope = exec::async_scope
 Asynchronous scope type.
 
using multiplexer_type = io::execution::poll_multiplexer
 The io multiplexer type.
 
using triggers = io::execution::basic_triggers< multiplexer_type >
 The io triggers type.
 
using socket_dialog = triggers::socket_dialog
 The socket dialog type.
 
using socket_type = io::socket::native_socket_type
 The socket type.
 
using signal_mask = std::uint64_t
 The signal mask type.
 
using interrupt_source = timers::socketpair_interrupt_source_t
 Interrupt source type.
 
using timers_type = timers::timers< interrupt_source >
 The timers type.
 
using clock = std::chrono::steady_clock
 The clock type.
 
using duration = std::chrono::milliseconds
 The duration type.
 
- Public Attributes inherited from net::service::async_context
timers_type timers
 The event loop timers.
 
async_scope scope
 The asynchronous scope.
 
triggers poller
 The poll triggers.
 
std::atomic< signal_masksigmask
 The active signal mask.
 
std::atomic< context_statesstate {PENDING}
 A counter that tracks the context state.
 

Detailed Description

template<ServiceLike Service>
class net::service::basic_context_thread< Service >

A threaded asynchronous service.

This class runs the provided service in a separate thread with an asynchronous context.

Template Parameters
ServiceThe service to run.

Member Function Documentation

◆ start()

template<ServiceLike Service>
template<typename... Args>
auto net::service::basic_context_thread< Service >::start ( Args &&...  args) -> void

Start the asynchronous service.

This starts the provided service in a separate thread with the provided asynchronous context.

Template Parameters
ArgsArgument types for constructing the Service.
Parameters
argsThe arguments to forward to the Service constructor.

The documentation for this class was generated from the following file: