1#ifndef UVW_HANDLE_INCLUDE_H
2#define UVW_HANDLE_INCLUDE_H
22template<
typename T,
typename U,
typename... E>
25 static void close_callback(uv_handle_t *hndl) {
26 handle<T, U, E...> &ref = *(
static_cast<T *
>(hndl->data));
27 [[maybe_unused]]
auto ptr = ref.shared_from_this();
32 uv_handle_t *as_uv_handle() {
33 return reinterpret_cast<uv_handle_t *
>(this->
raw());
36 const uv_handle_t *as_uv_handle()
const {
37 return reinterpret_cast<const uv_handle_t *
>(this->
raw());
65 handle_type
type() const noexcept {
89 return !!uv_is_active(as_uv_handle());
101 return !!uv_is_closing(as_uv_handle());
125 uv_ref(as_uv_handle());
135 uv_unref(as_uv_handle());
143 return !!uv_has_ref(as_uv_handle());
150 std::size_t
size() const noexcept {
151 return uv_handle_size(as_uv_handle()->
type);
168 auto err = uv_send_buffer_size(as_uv_handle(), &value);
169 return err ? err : value;
184 return uv_send_buffer_size(as_uv_handle(), &value);
201 auto err = uv_recv_buffer_size(as_uv_handle(), &value);
202 return err ? err : value;
217 return uv_recv_buffer_size(as_uv_handle(), &value);
243 uv_fileno(as_uv_handle(), &
fd);
os_file_descriptor fd() const
Gets the platform dependent file descriptor equivalent.
bool referenced() const noexcept
Checks if the given handle referenced.
void reference() noexcept
Reference the given handle.
void close() noexcept
Request handle to be closed.
std::size_t size() const noexcept
Returns the size of the underlying handle type.
int recv_buffer_size()
Gets the size of the receive buffer used for the socket.
handle_category category() const noexcept
Gets the category of the handle.
void unreference() noexcept
Unreference the given handle.
handle_type type() const noexcept
Gets the type of the handle.
int send_buffer_size(int value)
Sets the size of the send buffer used for the socket.
bool active() const noexcept
Checks if the handle is active.
int send_buffer_size()
Gets the size of the send buffer used for the socket.
int recv_buffer_size(int value)
Sets the size of the receive buffer used for the socket.
bool closing() const noexcept
Checks if a handle is closing or closed.
Common class for almost all the resources available in uvw.
details::uv_type_wrapper< uv_os_fd_t > os_file_descriptor
details::uv_type_wrapper< uv_handle_type > handle_category
static handle_type guess_handle(handle_category category) noexcept
Gets the type of the handle given a category.
const U * raw() const noexcept
Gets the underlying raw data structure.