uvcc
libuv C++ bindings
uv::handle Class Reference

The base class for the libuv handles. More...

#include "handle-base.hpp"

Inheritance diagram for uv::handle:
uv::async uv::check uv::fs_event uv::idle uv::io uv::poll uv::prepare uv::process uv::signal uv::timer

Public Types

using uv_t = ::uv_handle_t
 
using on_destroy_t = std::function< void(void *_data) >
 The function type of the callback called when the handle has been closed and about to be destroyed. More...
 

Public Member Functions

 handle (const handle &_that)
 
handleoperator= (const handle &_that)
 
 handle (handle &&_that) noexcept
 
handleoperator= (handle &&_that) noexcept
 
void swap (handle &_that) noexcept
 
std::uintptr_t id () const noexcept
 The unique ID of the instance managed by this handle variable or 0 if the handle is void.
 
long nrefs () const noexcept
 The current number of existing references to the same object as this handle variable refers to.
 
int uv_status () const noexcept
 The status value returned by the last executed libuv API function on this handle.
 
on_destroy_ton_destroy () const noexcept
 
::uv_handle_type type () const noexcept
 The tag indicating the libuv type of the handle.
 
const char * type_name () const noexcept
 A string containing the name of the handle type.
 
uv::loop loop () const noexcept
 The libuv loop where the handle is running on. More...
 
void *& data () const noexcept
 The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field.
 
int is_active () const noexcept
 Check if the handle is active. More...
 
int is_closing () const noexcept
 Check if the handle is closing or closed. More...
 
::uv_os_fd_t fileno () const noexcept
 Get the platform dependent handle/file descriptor. More...
 
 operator const uv_t * () const noexcept
 
 operator uv_t * () noexcept
 
 operator bool () const noexcept
 Equivalent to (id() and uv_status() >= 0).
 
Functions to detach/attach a handle to the libuv loop for processing handle's events:

They provide access to the libuv API functions to reference/un-reference the given handle by the event loop that the handle is running on: uv_ref(), uv_unref(), uv_has_ref().

See also
libuv API documentation: Reference counting.
void attached (bool _state) const noexcept
 
bool attached () const noexcept
 

Detailed Description

The base class for the libuv handles.

Derived classes conceptually are just interfaces to the data stored in the base class, so there are no any virtual member functions.

See also
libuv API documentation: uv_handle_t — Base handle.

Definition at line 33 of file handle-base.hpp.

Member Typedef Documentation

◆ on_destroy_t

using uv::handle::on_destroy_t = std::function< void(void *_data) >

The function type of the callback called when the handle has been closed and about to be destroyed.

See also
libuv API documentation: uv_close_cb, uv_close().

Definition at line 45 of file handle-base.hpp.

Member Function Documentation

◆ loop()

uv::loop uv::handle::loop ( ) const
inlinenoexcept

The libuv loop where the handle is running on.

It is guaranteed that it will be a valid instance at least within the callback of the requests running on the handle.

Definition at line 302 of file handle-base.hpp.

◆ is_active()

int uv::handle::is_active ( ) const
inlinenoexcept

Check if the handle is active.

See also
libuv API documentation: uv_is_active().

Definition at line 330 of file handle-base.hpp.

◆ is_closing()

int uv::handle::is_closing ( ) const
inlinenoexcept

Check if the handle is closing or closed.

See also
libuv API documentation: uv_is_closing().

Definition at line 334 of file handle-base.hpp.

◆ fileno()

::uv_os_fd_t uv::handle::fileno ( ) const
inlinenoexcept

Get the platform dependent handle/file descriptor.

See also
libuv API documentation: uv_fileno().

Definition at line 365 of file handle-base.hpp.


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