summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-20 20:52:53 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-20 23:22:53 (GMT)
commitfb7ee82271cabed2197e1ed0c5be70453184e4e2 (patch)
treef736ec77cbec9bf318132defbe29cdc045725441
parent9dd14b2946eb821c1b8e5a5a8f81653710826a01 (diff)
downloadCMake-fb7ee82271cabed2197e1ed0c5be70453184e4e2.zip
CMake-fb7ee82271cabed2197e1ed0c5be70453184e4e2.tar.gz
CMake-fb7ee82271cabed2197e1ed0c5be70453184e4e2.tar.bz2
cmUVHandlePtr: Add uv_idle_ptr::{start,stop} methods
These were missing w.r.t. the pattern established for other handle wrappers.
-rw-r--r--Source/cmUVHandlePtr.cxx12
-rw-r--r--Source/cmUVHandlePtr.h4
-rw-r--r--Tests/CMakeLib/testUVHandlePtr.cxx13
3 files changed, 28 insertions, 1 deletions
diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx
index ecd9030..ca295e3 100644
--- a/Source/cmUVHandlePtr.cxx
+++ b/Source/cmUVHandlePtr.cxx
@@ -266,6 +266,18 @@ int uv_idle_ptr::init(uv_loop_t& loop, void* data)
return uv_idle_init(&loop, *this);
}
+int uv_idle_ptr::start(uv_idle_cb cb)
+{
+ assert(this->handle);
+ return uv_idle_start(*this, cb);
+}
+
+void uv_idle_ptr::stop()
+{
+ assert(this->handle);
+ uv_idle_stop(*this);
+}
+
template class uv_handle_ptr_base_<uv_handle_t>;
#define UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(NAME) \
diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h
index 7f70b36..7617415 100644
--- a/Source/cmUVHandlePtr.h
+++ b/Source/cmUVHandlePtr.h
@@ -201,6 +201,10 @@ struct uv_idle_ptr : public uv_handle_ptr_<uv_idle_t>
CM_INHERIT_CTOR(uv_idle_ptr, uv_handle_ptr_, <uv_idle_t>);
int init(uv_loop_t& loop, void* data = nullptr);
+
+ int start(uv_idle_cb cb);
+
+ void stop();
};
struct uv_signal_ptr : public uv_handle_ptr_<uv_signal_t>
diff --git a/Tests/CMakeLib/testUVHandlePtr.cxx b/Tests/CMakeLib/testUVHandlePtr.cxx
index d6fdb77..3c070b0 100644
--- a/Tests/CMakeLib/testUVHandlePtr.cxx
+++ b/Tests/CMakeLib/testUVHandlePtr.cxx
@@ -19,7 +19,7 @@ static bool testIdle()
cm::uv_idle_ptr idle;
idle.init(*loop, &idled);
- uv_idle_start(idle, cb);
+ idle.start(cb);
uv_run(loop, UV_RUN_DEFAULT);
if (!idled) {
@@ -27,6 +27,17 @@ static bool testIdle()
return false;
}
+ idled = false;
+
+ idle.start(cb);
+ idle.stop();
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ if (idled) {
+ std::cerr << "uv_idle_ptr::stop did not stop callback" << std::endl;
+ return false;
+ }
+
return true;
}