fix: delete UvTaskRunner's timers only after they're closed (#43561)

* fix: free UvTaskRunner timers only after they are closed

* refactor: UvTaskRunner now holds UvHandles
This commit is contained in:
Charles Kerr 2024-09-06 07:16:56 -05:00 committed by GitHub
parent 25f4691e78
commit cc5aa65cb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 35 deletions

View file

@ -9,7 +9,7 @@
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "uv.h" // NOLINT(build/include_directory)
#include "shell/common/node_bindings.h"
namespace base {
class Location;
@ -38,12 +38,10 @@ class UvTaskRunner : public base::SingleThreadTaskRunner {
private:
~UvTaskRunner() override;
static void OnTimeout(uv_timer_t* timer);
static void OnClose(uv_handle_t* handle);
raw_ptr<uv_loop_t> loop_;
std::map<uv_timer_t*, base::OnceClosure> tasks_;
std::map<UvHandle<uv_timer_t>, base::OnceClosure, UvHandleCompare> tasks_;
};
} // namespace electron