uvco 0.1
Loading...
Searching...
No Matches
close.h
Go to the documentation of this file.
1// uvco (c) 2023 Lewin Bormann. See LICENSE for specific terms.
2
3#pragma once
4
5#include <boost/assert.hpp>
6#include <uv.h>
7
9
10namespace uvco {
11
16
17void onCloseCallback(uv_handle_t *handle);
18
19template <typename Handle> bool isClosed(const Handle *h) {
20 return 0 != uv_is_closing((uv_handle_t *)h);
21}
22
36template <typename Handle, typename CloserArg>
37void closeHandle(Handle *handle,
38 void (*closer)(CloserArg *, void (*)(uv_handle_t *))) {
39 BOOST_ASSERT(handle != nullptr);
40 resetData(handle);
41 closer((CloserArg *)handle, onCloseCallback);
42}
43
45template <typename Handle> void closeHandle(Handle *handle) {
46 closeHandle<Handle, uv_handle_t>(handle, uv_close);
47}
48
50
51} // namespace uvco
void onCloseCallback(uv_handle_t *handle)
Definition close.cc:10
bool isClosed(const Handle *h)
Definition close.h:19
void closeHandle(Handle *handle, void(*closer)(CloserArg *, void(*)(uv_handle_t *)))
Definition close.h:37
void resetData(Handle *handle)
Reset data pointer on handle to nullptr.
Definition internal_utils.h:83
Definition async_work.cc:18