mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibThread: Fix destroying background actions
In the old model, beforebc319d9e88
, the parent (the background thread) would delete us when it exits (i.e. never), so we had to keep track of our own refcount in order to destroy ourselves when we're done. Withbc319d9e88
, the parent keeps additional reference to us, so: * There should be no need to explicitly ref() ourselves * The unref() would not get rid of the last reference to us anymore The latter is why all the BackgroundAction's were getting leaked. Fix this by simply unparenting ourselves from the background thread when we're done.
This commit is contained in:
parent
ab9a0780e3
commit
cbf2881bf7
Notes:
sideshowbarker
2024-07-19 09:04:41 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/cbf2881bf71 Pull-request: https://github.com/SerenityOS/serenity/pull/1292
1 changed files with 4 additions and 4 deletions
|
@ -75,17 +75,17 @@ private:
|
|||
{
|
||||
LOCKER(all_actions().lock());
|
||||
|
||||
this->ref();
|
||||
all_actions().resource().enqueue([this] {
|
||||
m_result = m_action();
|
||||
if (m_on_complete) {
|
||||
Core::EventLoop::current().post_event(*this, make<Core::DeferredInvocationEvent>([this](auto&) {
|
||||
m_on_complete(m_result.release_value());
|
||||
this->unref();
|
||||
this->remove_from_parent();
|
||||
}));
|
||||
Core::EventLoop::wake();
|
||||
} else
|
||||
this->unref();
|
||||
} else {
|
||||
this->remove_from_parent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue