8 #include "resource.hpp" 28 template<
typename T,
typename U>
31 static void closeCallback(uv_handle_t *handle) {
33 auto ptr = ref.shared_from_this();
39 static void allocCallback(uv_handle_t *, std::size_t suggested, uv_buf_t *buf) {
40 auto size =
static_cast<unsigned int>(suggested);
41 *buf = uv_buf_init(
new char[size], size);
44 template<
typename F,
typename... Args>
45 bool initialize(F &&f, Args&&... args) {
47 auto err = std::forward<F>(f)(this->parent(), this->
get(), std::forward<Args>(args)...);
59 template<
typename F,
typename... Args>
60 void invoke(F &&f, Args&&... args) {
61 auto err = std::forward<F>(f)(std::forward<Args>(args)...);
90 HandleType
type() const noexcept
override {
114 return !(uv_is_active(this->
template get<uv_handle_t>()) == 0);
126 return !(uv_is_closing(this->
template get<uv_handle_t>()) == 0);
151 uv_ref(this->
template get<uv_handle_t>());
161 uv_unref(this->
template get<uv_handle_t>());
169 return !(uv_has_ref(this->
template get<uv_handle_t>()) == 0);
176 std::size_t
size() const noexcept {
177 return uv_handle_size(this->
template get<uv_handle_t>()->type);
193 auto err = uv_send_buffer_size(this->
template get<uv_handle_t>(), &value);
194 return err ? 0 : value;
209 return (0 == uv_send_buffer_size(this->
template get<uv_handle_t>(), &value));
225 auto err = uv_recv_buffer_size(this->
template get<uv_handle_t>(), &value);
226 return err ? 0 : value;
241 return (0 == uv_recv_buffer_size(this->
template get<uv_handle_t>(), &value));
268 uv_fileno(this->
template get<uv_handle_t>(), &fd);
Event emitter base class.
std::size_t size() const noexcept
Returns the size of the underlying handle type.
bool recvBufferSize(int value)
Sets the size of the receive buffer used for the socket.
details::UVTypeWrapper< uv_os_fd_t > OSFileDescriptor
bool sendBufferSize(int value)
Sets the size of the send buffer used for the socket.
HandleType type() const noexcept override
Gets the type of the handle.
void close() noexcept override
Request handle to be closed.
details::UVTypeWrapper< uv_handle_type > HandleCategory
Common class for almost all the resources available in uvw.
bool active() const noexcept override
Checks if the handle is active.
static HandleType guessHandle(HandleCategory category) noexcept
Gets the type of the handle given a category.
HandleCategory category() const noexcept override
Gets the category of the handle.
bool closing() const noexcept override
Checks if a handle is closing or closed.
OSFileDescriptor fileno() const
Gets the platform dependent file descriptor equivalent.
void unreference() noexcept override
Unreference the given handle.
bool referenced() const noexcept override
Checks if the given handle referenced.
int sendBufferSize()
Gets the size of the send buffer used for the socket.
void reference() noexcept override
Reference the given handle.
int recvBufferSize()
Gets the size of the receive buffer used for the socket.