Net++
A class-based C++ encapsulation over the POSIX Sockets API
Loading...
Searching...
No Matches
async::IOContext Class Reference

Handles the event loop. More...

#include <io_context.hpp>

Inheritance diagram for async::IOContext:

Public Types

using io_context_ptr = std::shared_ptr< async::IOContext >
 

Public Member Functions

 IOContext ()
 IOContext constructor.
 
 IOContext (IOContext &&other) noexcept
 IOContext move constructor.
 
IOContextoperator= (IOContext &&other) noexcept
 IOContext move assignment operator.
 
io_context_ptr create ()
 Creates an instance of IOContext wrapped in shared_ptr.
 
event_base * c_base () const
 Gives a pointer to the event base struct for libevent calls.
 
void run () const
 Runs the event loop.
 

Detailed Description

Handles the event loop.

Uses libevent under the hood to dispatch callbacks upon event

Member Typedef Documentation

◆ io_context_ptr

Constructor & Destructor Documentation

◆ IOContext() [1/2]

async::IOContext::IOContext ( )

IOContext constructor.

Allocates memory for, and initializes the underlying event base handle

◆ IOContext() [2/2]

async::IOContext::IOContext ( IOContext &&  other)
noexcept

IOContext move constructor.

Acquires base handle from the source IOContext and invalidates base_ property of the source

Parameters
otherThe source IOContext

Member Function Documentation

◆ c_base()

event_base * async::IOContext::c_base ( ) const

Gives a pointer to the event base struct for libevent calls.

Returns
A non-owning pointer to the underlying handle

◆ create()

io_context_ptr async::IOContext::create ( )

Creates an instance of IOContext wrapped in shared_ptr.

Returns
The shared_ptr to the new IOContext instance

◆ operator=()

IOContext & async::IOContext::operator= ( IOContext &&  other)
noexcept

IOContext move assignment operator.

Invalidates the current event base handle and acquires the event base handle from the source IOContext

Parameters
otherThe source IOContext
Returns
A non-const lvalue reference to the acquiring IOContext

◆ run()

void async::IOContext::run ( ) const

Runs the event loop.


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