summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-20 20:52:07 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-20 23:22:30 (GMT)
commit9dd14b2946eb821c1b8e5a5a8f81653710826a01 (patch)
tree2a4ddd6f8a03b6f742c2e54ea02b92888b02710a
parent8908f277d94ad9e0a1e04a2d9a8c69db955265e9 (diff)
downloadCMake-9dd14b2946eb821c1b8e5a5a8f81653710826a01.zip
CMake-9dd14b2946eb821c1b8e5a5a8f81653710826a01.tar.gz
CMake-9dd14b2946eb821c1b8e5a5a8f81653710826a01.tar.bz2
cmUVHandlePtr: Add uv_timer_ptr::stop method
This was missing w.r.t. the pattern established for other handle wrappers.
-rw-r--r--Source/cmUVHandlePtr.cxx6
-rw-r--r--Source/cmUVHandlePtr.h2
-rw-r--r--Tests/CMakeLib/testUVHandlePtr.cxx10
3 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx
index 951ef3b..ecd9030 100644
--- a/Source/cmUVHandlePtr.cxx
+++ b/Source/cmUVHandlePtr.cxx
@@ -241,6 +241,12 @@ int uv_timer_ptr::start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat)
return uv_timer_start(*this, cb, timeout, repeat);
}
+void uv_timer_ptr::stop()
+{
+ assert(this->handle);
+ uv_timer_stop(*this);
+}
+
#ifndef CMAKE_BOOTSTRAP
uv_tty_ptr::operator uv_stream_t*() const
{
diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h
index e1bf0d0..7f70b36 100644
--- a/Source/cmUVHandlePtr.h
+++ b/Source/cmUVHandlePtr.h
@@ -238,6 +238,8 @@ struct uv_timer_ptr : public 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);
+
+ void stop();
};
struct uv_tty_ptr : public uv_handle_ptr_<uv_tty_t>
diff --git a/Tests/CMakeLib/testUVHandlePtr.cxx b/Tests/CMakeLib/testUVHandlePtr.cxx
index 02f8954..d6fdb77 100644
--- a/Tests/CMakeLib/testUVHandlePtr.cxx
+++ b/Tests/CMakeLib/testUVHandlePtr.cxx
@@ -53,6 +53,16 @@ static bool testTimer()
return false;
}
+ timed = false;
+ timer.start(cb, 10, 0);
+ timer.stop();
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ if (timed) {
+ std::cerr << "uv_timer_ptr::stop did not stop callback" << std::endl;
+ return false;
+ }
+
return true;
}