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

* fix: free UvTaskRunner timers only after they are closed

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: UvTaskRunner now holds UvHandles

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2024-09-06 11:18:52 -05:00 committed by GitHub
parent a461a95b60
commit 9da190f786
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 35 deletions

View file

@ -10,7 +10,7 @@
#include "base/functional/callback.h"
#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;
@ -39,12 +39,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