1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibThreading: Remove Thread's inheritance from Core::EventReceiver

Inheritance from `EventReceiver` on the `Thread` class was only used in
the `BackgroundAction` class, where the children vector was keeping the
action alive until the work was completed. However, this can be
accomplished by instead capturing a `NonnullRefPtr` of `this`. The work
function can then avoid having to remove the `BackgroundAction` from
its parent `Thread` when the work completes.
This commit is contained in:
Zaggy1024 2023-08-06 01:21:49 -05:00 committed by Andrew Kaster
parent 925afcd4b0
commit 71df0ee994
3 changed files with 28 additions and 29 deletions

View file

@ -12,8 +12,7 @@
namespace Threading {
Thread::Thread(Function<intptr_t()> action, StringView thread_name)
: Core::EventReceiver(nullptr)
, m_action(move(action))
: m_action(move(action))
, m_thread_name(thread_name.is_null() ? ""sv : thread_name)
{
}