uvco 0.1
Loading...
Searching...
No Matches
uvco::UvHandleDeleter Struct Reference

#include <internal_utils.h>

Public Member Functions

template<typename Handle>
void operator() (Handle *handle)

Static Public Member Functions

static void del (uv_handle_t *handle)

Detailed Description

A polymorphic functor for deleting a uv_handle_t. It dispatches to the correct uv_... function based on the handle's type. This is necessary for classes like StreamBase which contain a pointer to a uv_handle_t, but don't know the exact type of the handle.

Member Function Documentation

◆ del()

void uvco::UvHandleDeleter::del ( uv_handle_t * handle)
static
32 {
33 // Use dynamic type info tracked by libuv to delete the handle correctly.
34 switch (handle->type) {
35 case UV_ASYNC:
36 delete (uv_async_t *)handle;
37 break;
38 case UV_CHECK:
39 delete (uv_check_t *)handle;
40 break;
41 case UV_FS_EVENT:
42 delete (uv_fs_event_t *)handle;
43 break;
44 case UV_FS_POLL:
45 delete (uv_fs_poll_t *)handle;
46 break;
47 case UV_HANDLE:
48 delete handle;
49 break;
50 case UV_IDLE:
51 delete (uv_idle_t *)handle;
52 break;
53 case UV_POLL:
54 delete (uv_poll_t *)handle;
55 break;
56 case UV_PREPARE:
57 delete (uv_prepare_t *)handle;
58 break;
59 case UV_PROCESS:
60 delete (uv_process_t *)handle;
61 break;
62 case UV_STREAM:
63 delete (uv_stream_t *)handle;
64 break;
65 case UV_TCP:
66 delete (uv_tcp_t *)handle;
67 break;
68 case UV_UDP:
69 delete (uv_udp_t *)handle;
70 break;
71 case UV_NAMED_PIPE:
72 delete (uv_pipe_t *)handle;
73 break;
74 case UV_TTY:
75 delete (uv_tty_t *)handle;
76 break;
77 case UV_TIMER:
78 delete (uv_timer_t *)handle;
79 break;
80 default:
81 fmt::print("WARN: unhandled handle type {}\n", (int)handle->type);
82 BOOST_ASSERT_MSG(false, "unhandled handle type");
83 }
84}

◆ operator()()

template<typename Handle>
void uvco::UvHandleDeleter::operator() ( Handle * handle)
inline
117 {
118 del((uv_handle_t *)handle);
119 }
static void del(uv_handle_t *handle)
Definition internal_utils.cc:32

The documentation for this struct was generated from the following files: