uvco 0.1
Loading...
Searching...
No Matches
Close

Functions

void uvco::onCloseCallback (uv_handle_t *handle)
template<typename Handle>
bool uvco::isClosed (const Handle *h)
template<typename Handle, typename CloserArg>
void uvco::closeHandle (Handle *handle, void(*closer)(CloserArg *, void(*)(uv_handle_t *)))
template<typename Handle>
void uvco::closeHandle (Handle *handle)
 Specialization for uv_handle_t handles.

Detailed Description

Internally used by various classes to safely close and deallocate libuv handles.

Function Documentation

◆ closeHandle() [1/2]

template<typename Handle>
void uvco::closeHandle ( Handle * handle)

Specialization for uv_handle_t handles.

45 {
46 closeHandle<Handle, uv_handle_t>(handle, uv_close);
47}
void closeHandle(Handle *handle, void(*closer)(CloserArg *, void(*)(uv_handle_t *)))
Definition close.h:37

◆ closeHandle() [2/2]

template<typename Handle, typename CloserArg>
void uvco::closeHandle ( Handle * handle,
void(* closer )(CloserArg *, void(*)(uv_handle_t *)) )

closeHandle() takes care of safely closing a handle. Canonically you should await the returned promise to be sure that the handle is closed. However, if the promise is dropped and thus the coroutine cancelled, the libuv close operation will still be carried out safely in the background.

The template types and arguments are expressed as they are to support, e.g., uv_tcp_close_reset.

closeHandle() has an intricate implementation which allows a safe synchronous call, e.g. from destructors: In that case, the handle will still be closed correctly, but the handle itself will also be freed. This is always done when it detects that the closeHandle coroutine has been cancelled (due to the returned promise having been dropped).

38 {
39 BOOST_ASSERT(handle != nullptr);
40 resetData(handle);
41 closer((CloserArg *)handle, onCloseCallback);
42}
void onCloseCallback(uv_handle_t *handle)
Definition close.cc:10
void resetData(Handle *handle)
Reset data pointer on handle to nullptr.
Definition internal_utils.h:83

◆ isClosed()

template<typename Handle>
bool uvco::isClosed ( const Handle * h)
19 {
20 return 0 != uv_is_closing((uv_handle_t *)h);
21}

◆ onCloseCallback()

void uvco::onCloseCallback ( uv_handle_t * handle)
10 {
11 BOOST_ASSERT(dataIsNull(handle));
13}
bool dataIsNull(Handle *handle)
Check if handle data is null.
Definition internal_utils.h:101
static void del(uv_handle_t *handle)
Definition internal_utils.cc:32