1#ifndef UVW_HANDLE_INCLUDE_H
2#define UVW_HANDLE_INCLUDE_H
25template<
typename T,
typename U>
28 static void closeCallback(uv_handle_t *handle) {
30 [[maybe_unused]]
auto ptr = ref.shared_from_this();
35 static void allocCallback(uv_handle_t *, std::size_t suggested, uv_buf_t *buf) {
36 auto size =
static_cast<unsigned int>(suggested);
37 *buf = uv_buf_init(
new char[
size],
size);
40 template<
typename F,
typename... Args>
41 bool initialize(F &&f, Args &&...args) {
43 if(
auto err = std::forward<F>(f)(this->parent(), this->get(), std::forward<Args>(args)...); err) {
53 template<
typename F,
typename... Args>
54 void invoke(F &&f, Args &&...args) {
55 auto err = std::forward<F>(f)(std::forward<Args>(args)...);
84 HandleType
type() const noexcept {
108 return !(uv_is_active(this->
template get<uv_handle_t>()) == 0);
120 return !(uv_is_closing(this->
template get<uv_handle_t>()) == 0);
145 uv_ref(this->
template get<uv_handle_t>());
155 uv_unref(this->
template get<uv_handle_t>());
163 return !(uv_has_ref(this->
template get<uv_handle_t>()) == 0);
170 std::size_t
size() const noexcept {
171 return uv_handle_size(this->
template get<uv_handle_t>()->
type);
187 auto err = uv_send_buffer_size(this->
template get<uv_handle_t>(), &value);
188 return err ? 0 : value;
203 return (0 == uv_send_buffer_size(this->
template get<uv_handle_t>(), &value));
219 auto err = uv_recv_buffer_size(this->
template get<uv_handle_t>(), &value);
220 return err ? 0 : value;
235 return (0 == uv_recv_buffer_size(this->
template get<uv_handle_t>(), &value));
262 uv_fileno(this->
template get<uv_handle_t>(), &
fd);
Event emitter base class.
bool closing() const noexcept
Checks if a handle is closing or closed.
void reference() noexcept
Reference the given handle.
HandleCategory category() const noexcept
Gets the category of the handle.
int sendBufferSize()
Gets the size of the send buffer used for the socket.
bool recvBufferSize(int value)
Sets the size of the receive buffer used for the socket.
HandleType type() const noexcept
Gets the type of the handle.
bool active() const noexcept
Checks if the handle is active.
void unreference() noexcept
Unreference the given handle.
std::size_t size() const noexcept
Returns the size of the underlying handle type.
void close() noexcept
Request handle to be closed.
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 referenced() const noexcept
Checks if the given handle referenced.
OSFileDescriptor fd() const
Gets the platform dependent file descriptor equivalent.
Common class for almost all the resources available in uvw.
details::UVTypeWrapper< uv_os_fd_t > OSFileDescriptor
details::UVTypeWrapper< uv_handle_type > HandleCategory
static HandleType guessHandle(HandleCategory category) noexcept
Gets the type of the handle given a category.