1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 12:55:09 +00:00

LibCore: Cancel jobs on event loop exit

This important feature was regressed with the recent architectural
change.
This commit is contained in:
kleines Filmröllchen 2023-05-11 21:58:40 +02:00 committed by Andrew Kaster
parent f2609281a3
commit 7704d89496
3 changed files with 12 additions and 0 deletions

View file

@ -11,6 +11,7 @@
#include <LibCore/Promise.h>
#include <LibCore/ThreadEventQueue.h>
#include <LibThreading/Mutex.h>
#include <errno.h>
namespace Core {
@ -76,6 +77,15 @@ void ThreadEventQueue::add_job(NonnullRefPtr<Promise<NonnullRefPtr<Object>>> pro
m_private->pending_promises.append(move(promise));
}
void ThreadEventQueue::cancel_all_pending_jobs()
{
Threading::MutexLocker lock(m_private->mutex);
for (auto const& promise : m_private->pending_promises)
promise->cancel(Error::from_errno(ECANCELED));
m_private->pending_promises.clear();
}
size_t ThreadEventQueue::process()
{
decltype(m_private->queued_events) events;