This was missing w.r.t. the pattern established for other handle wrappers.
@@ -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
{
@@ -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>
@@ -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;