uvw 3.1.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
uvw::handle< T, U, E > Class Template Reference

Handle base class. More...

#include <handle.hpp>

Inheritance diagram for uvw::handle< T, U, E >:
Inheritance graph
[legend]
Collaboration diagram for uvw::handle< T, U, E >:
Collaboration graph
[legend]

Public Member Functions

handle_category category () const noexcept
 Gets the category of the handle.
 
handle_type type () const noexcept
 Gets the type of the handle.
 
bool active () const noexcept
 Checks if the handle is active.
 
bool closing () const noexcept
 Checks if a handle is closing or closed.
 
void close () noexcept
 Request handle to be closed.
 
void reference () noexcept
 Reference the given handle.
 
void unreference () noexcept
 Unreference the given handle.
 
bool referenced () const noexcept
 Checks if the given handle referenced.
 
std::size_t size () const noexcept
 Returns the size of the underlying handle type.
 
int send_buffer_size ()
 Gets the size of the send buffer used for the socket.
 
int send_buffer_size (int value)
 Sets the size of the send buffer used for the socket.
 
int recv_buffer_size ()
 Gets the size of the receive buffer used for the socket.
 
int recv_buffer_size (int value)
 Sets the size of the receive buffer used for the socket.
 
os_file_descriptor fd () const
 Gets the platform dependent file descriptor equivalent.
 
- Public Member Functions inherited from uvw::resource< T, U, close_event, E... >
std::shared_ptr< R > data () const
 Gets user-defined data. uvw won't use this field in any case.
 
void data (std::shared_ptr< void > udata)
 Sets arbitrary data. uvw won't use this field in any case.
 
- Public Member Functions inherited from uvw::uv_type< U >
virtual int init ()
 Initializes the handle.
 
loopparent () const noexcept
 Gets the loop from which the resource was originated.
 
const U * raw () const noexcept
 Gets the underlying raw data structure.
 
U * raw () noexcept
 Gets the underlying raw data structure.
 
- Public Member Functions inherited from uvw::emitter< T, E... >
void on (listener_t< U > f)
 Registers a long-lived listener with the event emitter.
 
void reset () noexcept
 Disconnects the listener for the given event type.
 
void reset () noexcept
 Disconnects all listeners.
 
bool has () const noexcept
 Checks if there is a listener registered for the specific event.
 

Detailed Description

template<typename T, typename U, typename... E>
class uvw::handle< T, U, E >

Handle base class.

Base type for all uvw handle types.

Definition at line 23 of file handle.hpp.

Member Function Documentation

◆ active()

template<typename T , typename U , typename... E>
bool uvw::handle< T, U, E >::active ( ) const
inlinenoexcept

Checks if the handle is active.

What active means depends on the type of handle:

  • An async_handle handle is always active and cannot be deactivated, except by closing it with uv_close().
  • A pipe, tcp, udp, etc. handle - basically any handle that deals with I/O - is active when it is doing something that involves I/O, like reading, writing, connecting, accepting new connections, etc.
  • A check, idle, timer, etc. handle is active when it has been started with a call to start().

Rule of thumb: if a handle of type foo_handle has a start() member method, then it’s active from the moment that method is called. Likewise, stop() deactivates the handle again.

Returns
True if the handle is active, false otherwise.

Definition at line 88 of file handle.hpp.

◆ category()

template<typename T , typename U , typename... E>
handle_category uvw::handle< T, U, E >::category ( ) const
inlinenoexcept

Gets the category of the handle.

A base handle offers no functionality to promote it to the actual handle type. By means of this function, an opaque value that identifies the category of the handle is made available to the users.

Returns
The actual category of the handle.

Definition at line 52 of file handle.hpp.

◆ close()

template<typename T , typename U , typename... E>
void uvw::handle< T, U, E >::close ( )
inlinenoexcept

Request handle to be closed.

This must be called on each handle before memory is released.
In-progress requests are cancelled and this can result in errors.

The handle will emit a close event when finished.

Definition at line 112 of file handle.hpp.

◆ closing()

template<typename T , typename U , typename... E>
bool uvw::handle< T, U, E >::closing ( ) const
inlinenoexcept

Checks if a handle is closing or closed.

This function should only be used between the initialization of the handle and the arrival of the close callback.

Returns
True if the handle is closing or closed, false otherwise.

Definition at line 100 of file handle.hpp.

◆ fd()

template<typename T , typename U , typename... E>
os_file_descriptor uvw::handle< T, U, E >::fd ( ) const
inline

Gets the platform dependent file descriptor equivalent.

Supported handles:

If invoked on a different handle, one that doesn’t have an attached file descriptor yet or one which was closed, an invalid value is returned.

See the official documentation for further details.

Returns
The file descriptor attached to the hande or a negative value in case of errors.

Definition at line 241 of file handle.hpp.

◆ recv_buffer_size() [1/2]

template<typename T , typename U , typename... E>
int uvw::handle< T, U, E >::recv_buffer_size ( )
inline

Gets the size of the receive buffer used for the socket.

Gets the size of the receive buffer that the operating system uses for the socket.
This function works for tcp, pipe and udp handles on Unix and for tcp and udp handles on Windows.
Note that Linux will return double the size of the original set value.

Returns
The size of the receive buffer, the underlying return value in case of errors.

Definition at line 199 of file handle.hpp.

◆ recv_buffer_size() [2/2]

template<typename T , typename U , typename... E>
int uvw::handle< T, U, E >::recv_buffer_size ( int  value)
inline

Sets the size of the receive buffer used for the socket.

Sets the size of the receive buffer that the operating system uses for the socket.
This function works for tcp, pipe and udp handles on Unix and for tcp and udp handles on Windows.
Note that Linux will set double the size.

Returns
Underlying return value.

Definition at line 216 of file handle.hpp.

◆ reference()

template<typename T , typename U , typename... E>
void uvw::handle< T, U, E >::reference ( )
inlinenoexcept

Reference the given handle.

References are idempotent, that is, if a handle is already referenced calling this function again will have no effect.

Definition at line 124 of file handle.hpp.

◆ referenced()

template<typename T , typename U , typename... E>
bool uvw::handle< T, U, E >::referenced ( ) const
inlinenoexcept

Checks if the given handle referenced.

Returns
True if the handle referenced, false otherwise.

Definition at line 142 of file handle.hpp.

◆ send_buffer_size() [1/2]

template<typename T , typename U , typename... E>
int uvw::handle< T, U, E >::send_buffer_size ( )
inline

Gets the size of the send buffer used for the socket.

Gets the size of the send buffer that the operating system uses for the socket.
This function works for tcp, pipeand udp handles on Unix and for tcp and udp handles on Windows.
Note that Linux will return double the size of the original set value.

Returns
The size of the send buffer, the underlying return value in case of errors.

Definition at line 166 of file handle.hpp.

◆ send_buffer_size() [2/2]

template<typename T , typename U , typename... E>
int uvw::handle< T, U, E >::send_buffer_size ( int  value)
inline

Sets the size of the send buffer used for the socket.

Sets the size of the send buffer that the operating system uses for the socket.
This function works for tcp, pipe and udp handles on Unix and for tcp and udp handles on Windows.
Note that Linux will set double the size.

Returns
Underlying return value.

Definition at line 183 of file handle.hpp.

◆ size()

template<typename T , typename U , typename... E>
std::size_t uvw::handle< T, U, E >::size ( ) const
inlinenoexcept

Returns the size of the underlying handle type.

Returns
The size of the underlying handle type.

Definition at line 150 of file handle.hpp.

◆ type()

template<typename T , typename U , typename... E>
handle_type uvw::handle< T, U, E >::type ( ) const
inlinenoexcept

Gets the type of the handle.

A base handle offers no functionality to promote it to the actual handle type. By means of this function, the type of the underlying handle as specified by handle_type is made available to the users.

Returns
The actual type of the handle.

Definition at line 65 of file handle.hpp.

◆ unreference()

template<typename T , typename U , typename... E>
void uvw::handle< T, U, E >::unreference ( )
inlinenoexcept

Unreference the given handle.

References are idempotent, that is, if a handle is not referenced calling this function again will have no effect.

Definition at line 134 of file handle.hpp.


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