pars 0.2.1
Loading...
Searching...
No Matches
pars::net::context Class Reference

#include <context.h>

Public Member Functions

 context (ev::enqueuer &r, nngxx::ctx &&c, const net::socket &s)
 
 ~context ()
 
 operator tool_view ()
 
void set_options (context_opt opts)
 
context_opt options () const
 
void send_aio (nngxx::aio_view &a)
 
void recv_aio (nngxx::aio_view &a)
 
template<ev::event_c event_t>
void send (event_t ev, pipe p)
 
void recv ()
 
void stop ()
 
int id () const
 
int socket_id () const
 
const net::socketsock () const
 
auto format_to (std::format_context &ctx) const -> decltype(ctx.out())
 

Detailed Description

Definition at line 45 of file context.h.

Constructor & Destructor Documentation

◆ context()

pars::net::context::context ( ev::enqueuer & r,
nngxx::ctx && c,
const net::socket & s )
inline

Definition at line 48 of file context.h.

49 : router_m{r}
50 , ctx_m{std::move(c)}
51 , sock_m{s}
52 {
53 }

◆ ~context()

pars::net::context::~context ( )
inline

Definition at line 55 of file context.h.

55{ stop(); }

References stop().

Here is the call graph for this function:

Member Function Documentation

◆ format_to()

auto pars::net::context::format_to ( std::format_context & ctx) const -> decltype(ctx.out())
inline

Definition at line 94 of file context.h.

95 {
96 return std::format_to(ctx.out(), "context #{}", id());
97 }
clev::own< nng_ctx > ctx
Definition ctx.h:39

◆ id()

int pars::net::context::id ( ) const
inline

Definition at line 88 of file context.h.

88{ return ctx_m.id(); }

◆ operator tool_view()

pars::net::context::operator tool_view ( )
inline

Definition at line 57 of file context.h.

57{ return tool_view{ctx_m}; }

◆ options()

context_opt pars::net::context::options ( ) const
inline

Definition at line 68 of file context.h.

69 {
70 return {.recv_timeout = ctx_m.get_recv_timeout().value_or_abort(),
71 .send_timeout = ctx_m.get_send_timeout().value_or_abort()};
72 }

◆ recv()

void pars::net::context::recv ( )
inline

Definition at line 84 of file context.h.

84{ op_m.recv(router_m, *this); }

Referenced by pars::net::context_registry::start_recv().

Here is the caller graph for this function:

◆ recv_aio()

void pars::net::context::recv_aio ( nngxx::aio_view & a)
inline

Definition at line 76 of file context.h.

76{ ctx_m.recv(a); }

◆ send()

template<ev::event_c event_t>
void pars::net::context::send ( event_t ev,
pipe p )
inline

Definition at line 79 of file context.h.

80 {
81 op_m.send(router_m, *this, p, ev);
82 }

◆ send_aio()

void pars::net::context::send_aio ( nngxx::aio_view & a)
inline

Definition at line 74 of file context.h.

74{ ctx_m.send(a); }

◆ set_options()

void pars::net::context::set_options ( context_opt opts)
inline

Definition at line 59 of file context.h.

60 {
61 if (opts.recv_timeout)
62 ctx_m.set_recv_timeout(*opts.recv_timeout).or_abort();
63
64 if (opts.send_timeout)
65 ctx_m.set_send_timeout(*opts.send_timeout).or_abort();
66 }

References pars::net::context_opt::recv_timeout, and pars::net::context_opt::send_timeout.

◆ sock()

const net::socket & pars::net::context::sock ( ) const
inline

Definition at line 92 of file context.h.

92{ return sock_m; }

◆ socket_id()

int pars::net::context::socket_id ( ) const
inline

Definition at line 90 of file context.h.

90{ return sock_m.id(); }

◆ stop()

void pars::net::context::stop ( )
inline

Definition at line 86 of file context.h.

86{ op_m.stop(); }

Referenced by ~context().

Here is the caller graph for this function:

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