diff options
author | Brad King <brad.king@kitware.com> | 2017-11-30 16:19:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-11-30 18:26:35 (GMT) |
commit | dd700e9bfb2a498632845e76ce95dd38bb866a7b (patch) | |
tree | 79fb14a5c887417275b704e9175a22af56517cc7 /Source | |
parent | 32cfa7b324de799eefb2f7370fb54b700d1a87a5 (diff) | |
download | CMake-dd700e9bfb2a498632845e76ce95dd38bb866a7b.zip CMake-dd700e9bfb2a498632845e76ce95dd38bb866a7b.tar.gz CMake-dd700e9bfb2a498632845e76ce95dd38bb866a7b.tar.bz2 |
cmUVHandlePtr: Add uv_timer_ptr
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmUVHandlePtr.cxx | 14 | ||||
-rw-r--r-- | Source/cmUVHandlePtr.h | 12 |
2 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx index 8ba93e5..78819a5 100644 --- a/Source/cmUVHandlePtr.cxx +++ b/Source/cmUVHandlePtr.cxx @@ -172,6 +172,18 @@ uv_pipe_ptr::operator uv_stream_t*() const } #ifdef CMAKE_BUILD_WITH_CMAKE +int uv_timer_ptr::init(uv_loop_t& loop, void* data) +{ + allocate(data); + return uv_timer_init(&loop, *this); +} + +int uv_timer_ptr::start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat) +{ + assert(handle); + return uv_timer_start(*this, cb, timeout, repeat); +} + uv_tty_ptr::operator uv_stream_t*() const { return reinterpret_cast<uv_stream_t*>(handle.get()); @@ -199,6 +211,8 @@ UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(stream) #ifdef CMAKE_BUILD_WITH_CMAKE UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(async) +UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(timer) + UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(tty) #endif } diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h index a251c5f..d3df69c 100644 --- a/Source/cmUVHandlePtr.h +++ b/Source/cmUVHandlePtr.h @@ -5,6 +5,7 @@ #include <algorithm> #include <cstddef> +#include <cstdint> #include <memory> #include <type_traits> @@ -164,6 +165,15 @@ struct uv_pipe_ptr : public uv_handle_ptr_<uv_pipe_t> int init(uv_loop_t& loop, int ipc, void* data = nullptr); }; +struct uv_timer_ptr : public uv_handle_ptr_<uv_timer_t> +{ + CM_PERFECT_FWD_CTOR(uv_timer_ptr, uv_handle_ptr_<uv_timer_t>); + + int init(uv_loop_t& loop, void* data = nullptr); + + int start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat); +}; + struct uv_tty_ptr : public uv_handle_ptr_<uv_tty_t> { CM_PERFECT_FWD_CTOR(uv_tty_ptr, uv_handle_ptr_<uv_tty_t>); @@ -192,6 +202,8 @@ UV_HANDLE_PTR_INSTANTIATE_EXTERN(pipe) UV_HANDLE_PTR_INSTANTIATE_EXTERN(stream) +UV_HANDLE_PTR_INSTANTIATE_EXTERN(timer) + UV_HANDLE_PTR_INSTANTIATE_EXTERN(tty) #undef UV_HANDLE_PTR_INSTANTIATE_EXTERN |