uvw 2.12.1
Loading...
Searching...
No Matches
uvw::Handle< T, U > Class Template Reference

Handle base class. More...

#include <handle.hpp>

Inheritance diagram for uvw::Handle< T, U >:
Collaboration diagram for uvw::Handle< T, U >:

Public Member Functions

HandleCategory category () const noexcept
 Gets the category of the handle.
 
HandleType 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 sendBufferSize ()
 Gets the size of the send buffer used for the socket.
 
bool sendBufferSize (int value)
 Sets the size of the send buffer used for the socket.
 
int recvBufferSize ()
 Gets the size of the receive buffer used for the socket.
 
bool recvBufferSize (int value)
 Sets the size of the receive buffer used for the socket.
 
OSFileDescriptor fd () const
 Gets the platform dependent file descriptor equivalent.
 
- Public Member Functions inherited from uvw::Resource< T, U >
template<typename R = void>
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::UnderlyingType< T, U >
Looploop () 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 >
template<typename E >
Connection< E > on (Listener< E > f)
 Registers a long-lived listener with the event emitter.
 
template<typename E >
Connection< E > once (Listener< E > f)
 Registers a short-lived listener with the event emitter.
 
template<typename E >
void erase (Connection< E > conn) noexcept
 Disconnects a listener from the event emitter.
 
template<typename E >
void clear () noexcept
 Disconnects all the listeners for the given event type.
 
void clear () noexcept
 Disconnects all the listeners.
 
template<typename E >
bool empty () const noexcept
 Checks if there are listeners registered for the specific event.
 
bool empty () const noexcept
 Checks if there are listeners registered with the event emitter.
 

Additional Inherited Members

- Public Types inherited from uvw::Emitter< T >
- Static Public Member Functions inherited from uvw::UnderlyingType< T, U >
template<typename... Args>
static std::shared_ptr< T > create (Args &&...args)
 Creates a new resource of the given type.
 
- Protected Types inherited from uvw::Resource< T, U >
- Protected Member Functions inherited from uvw::Resource< T, U >
- Protected Member Functions inherited from uvw::UnderlyingType< T, U >
- Protected Member Functions inherited from uvw::Emitter< T >

Detailed Description

template<typename T, typename U>
class uvw::Handle< T, U >

Handle base class.

Base type for all uvw handle types.

Definition at line 26 of file handle.hpp.

Member Function Documentation

◆ active()

template<typename T , typename U >
bool uvw::Handle< T, U >::active ( ) const
inlinenoexcept

Checks if the handle is active.

What active means depends on the type of handle:

  • An AsyncHandle handle is always active and cannot be deactivated, except by closing it with uv_close().
  • A PipeHandle, TCPHandle, UDPHandle, 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 CheckHandle, IdleHandle, TimerHandle, etc. handle is active when it has been started with a call to start().

Rule of thumb: if a handle of type FooHandle 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 107 of file handle.hpp.

◆ category()

template<typename T , typename U >
HandleCategory uvw::Handle< T, U >::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 71 of file handle.hpp.

◆ close()

template<typename T , typename U >
void uvw::Handle< T, U >::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 an ErrorEvent emitted.

The handle will emit a CloseEvent when finished.

Definition at line 132 of file handle.hpp.

◆ closing()

template<typename T , typename U >
bool uvw::Handle< T, U >::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 119 of file handle.hpp.

◆ fd()

template<typename T , typename U >
OSFileDescriptor uvw::Handle< T, U >::fd ( ) const
inline

Gets the platform dependent file descriptor equivalent.

Supported handles:

It will emit an ErrorEvent event if invoked on any other handle.
If a handle doesn’t have an attached file descriptor yet or the handle itself has been closed, an ErrorEvent event will be emitted.

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 260 of file handle.hpp.

◆ recvBufferSize() [1/2]

template<typename T , typename U >
int uvw::Handle< T, U >::recvBufferSize ( )
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 TCPHandle, PipeHandle and UDPHandle handles on Unix and for TCPHandle and UDPHandle handles on Windows.
Note that Linux will return double the size of the original set value.

Returns
The size of the receive buffer, 0 in case of errors.

Definition at line 217 of file handle.hpp.

◆ recvBufferSize() [2/2]

template<typename T , typename U >
bool uvw::Handle< T, U >::recvBufferSize ( 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 TCPHandle, PipeHandle and UDPHandle handles on Unix and for TCPHandle and UDPHandle handles on Windows.
Note that Linux will set double the size.

Returns
True in case of success, false otherwise.

Definition at line 234 of file handle.hpp.

◆ reference()

template<typename T , typename U >
void uvw::Handle< T, U >::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 144 of file handle.hpp.

◆ referenced()

template<typename T , typename U >
bool uvw::Handle< T, U >::referenced ( ) const
inlinenoexcept

Checks if the given handle referenced.

Returns
True if the handle referenced, false otherwise.

Definition at line 162 of file handle.hpp.

◆ sendBufferSize() [1/2]

template<typename T , typename U >
int uvw::Handle< T, U >::sendBufferSize ( )
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 TCPHandle, PipeHandle and UDPHandle handles on Unix and for TCPHandle and UDPHandle handles on Windows.
Note that Linux will return double the size of the original set value.

Returns
The size of the send buffer, 0 in case of errors.

Definition at line 185 of file handle.hpp.

◆ sendBufferSize() [2/2]

template<typename T , typename U >
bool uvw::Handle< T, U >::sendBufferSize ( 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 TCPHandle, PipeHandle and UDPHandle handles on Unix and for TCPHandle and UDPHandle handles on Windows.
Note that Linux will set double the size.

Returns
True in case of success, false otherwise.

Definition at line 202 of file handle.hpp.

◆ size()

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

Returns the size of the underlying handle type.

Returns
The size of the underlying handle type.

Definition at line 170 of file handle.hpp.

◆ type()

template<typename T , typename U >
HandleType uvw::Handle< T, U >::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 HandleType is made available to the users.

Returns
The actual type of the handle.

Definition at line 84 of file handle.hpp.

◆ unreference()

template<typename T , typename U >
void uvw::Handle< T, U >::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 154 of file handle.hpp.


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