WPILibC++ 2023.4.3-108-ge5452e3
|
#include <wpinet/uv/Handle.h>
Public Types | |
using | Type = uv_handle_type |
Public Member Functions | |
Handle (const Handle &)=delete | |
Handle (Handle &&)=delete | |
Handle & | operator= (const Handle &)=delete |
Handle & | operator= (Handle &&)=delete |
virtual | ~Handle () noexcept |
Type | GetType () const noexcept |
Get the type of the handle. More... | |
std::string_view | GetTypeName () const noexcept |
Get the name of the type of the handle. More... | |
std::shared_ptr< Loop > | GetLoop () const noexcept |
Get the loop where this handle runs. More... | |
Loop & | GetLoopRef () const noexcept |
Get the loop where this handle runs. More... | |
bool | IsActive () const noexcept |
Check if the handle is active. More... | |
bool | IsClosing () const noexcept |
Check if a handle is closing or closed. More... | |
void | Close () noexcept |
Request handle to be closed. More... | |
void | SetLoopClosing (bool loopClosing) noexcept |
Set if the loop is closing. More... | |
bool | IsLoopClosing () const noexcept |
Get the loop closing status. More... | |
void | Reference () noexcept |
Reference the given handle. More... | |
void | Unreference () noexcept |
Unreference the given handle. More... | |
bool | HasReference () const noexcept |
Check if the given handle is referenced. More... | |
size_t | RawSize () const noexcept |
Return the size of the underlying handle type. More... | |
uv_handle_t * | GetRawHandle () const noexcept |
Get the underlying handle data structure. More... | |
void | SetBufferAllocator (std::function< Buffer(size_t)> alloc, std::function< void(Buffer &)> dealloc) |
Set the functions used for allocating and releasing buffers. More... | |
void | FreeBuf (Buffer &buf) const noexcept |
Free a buffer. More... | |
template<typename T = void> | |
std::shared_ptr< T > | GetData () const |
Gets user-defined data. More... | |
void | SetData (std::shared_ptr< void > data) |
Sets user-defined data. More... | |
void | ReportError (int err) const |
Report an error. More... | |
Public Attributes | |
sig::Signal< Error > | error |
Error signal. More... | |
sig::Signal | closed |
Closed signal. More... | |
Protected Member Functions | |
Handle (uv_handle_t *uv_handle) | |
void | Keep () noexcept |
void | Release () noexcept |
void | ForceClosed () noexcept |
template<typename F , typename... Args> | |
bool | Invoke (F &&f, Args &&... args) const |
Static Protected Member Functions | |
static void | AllocBuf (uv_handle_t *handle, size_t size, uv_buf_t *buf) |
static void | DefaultFreeBuf (Buffer &buf) |
Handles are not moveable or copyable and cannot be directly constructed. This class provides shared_ptr ownership and shared_from_this. Use the specific handle type Create() functions to create handles.
using wpi::uv::Handle::Type = uv_handle_type |
|
delete |
|
delete |
|
virtualnoexcept |
|
inlineexplicitprotected |
|
staticprotected |
|
noexcept |
|
staticprotected |
|
inlineprotectednoexcept |
|
inlinenoexcept |
Free a buffer.
Uses the function provided to SetBufFree() or Buffer::Deallocate by default.
buf | The buffer |
|
inline |
Gets user-defined data.
|
inlinenoexcept |
Get the loop where this handle runs.
|
inlinenoexcept |
Get the loop where this handle runs.
|
inlinenoexcept |
Get the underlying handle data structure.
|
inlinenoexcept |
Get 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 Type is made available.
|
inlinenoexcept |
Get the name of the type of the handle.
E.g. "pipe" for pipe handles.
|
inlinenoexcept |
Check if the given handle is referenced.
|
inlineprotected |
|
inlinenoexcept |
Check if the handle is active.
What active means depends on the type of handle:
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.
|
inlinenoexcept |
Check 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.
|
inlinenoexcept |
Get the loop closing status.
This can be used from closed() in order to tell if a closing loop is the reason for the close, or another reason.
|
inlineprotectednoexcept |
|
inlinenoexcept |
Return the size of the underlying handle type.
|
inlinenoexcept |
Reference the given handle.
References are idempotent, that is, if a handle is already referenced calling this function again will have no effect.
|
inlineprotectednoexcept |
|
inline |
Report an error.
err | Error code |
|
inline |
Set the functions used for allocating and releasing buffers.
The size passed to the allocator function is a "suggested" size–it's just an indication, not related in any way to the pending data to be read. The user is free to allocate the amount of memory they decide. For example, applications with custom allocation schemes may decide to use a different size which matches the memory chunks they already have for other purposes.
alloc | Allocation function |
dealloc | Deallocation function |
|
inline |
Sets user-defined data.
data | User-defined arbitrary data. |
|
inlinenoexcept |
Set if the loop is closing.
This is set during EventLoopRunner.Stop(), and can be used for other cases to indicate the loop should be closing. For instance for a uv_walk loop can use this to close existing handles.
loopClosing | true to set the loop currently in closing stages. |
|
inlinenoexcept |
Unreference the given handle.
References are idempotent, that is, if a handle is not referenced calling this function again will have no effect.
sig::Signal wpi::uv::Handle::closed |
Closed signal.
sig::Signal<Error> wpi::uv::Handle::error |
Error signal.