Commit Graph

14 Commits

Author SHA1 Message Date
R-Goc
02bb892d7a LibThreading/LibSync: Split out sync primitives
This commit splits out synchronization primitives from LibThreading into
LibSync. This is because LibThreading depends on LibCore, while LibCore
needs the synchronization primitives from LibThreading. This worked
while they were header only, but when I tried to add an implementation
file it ran into the circular dependency. To abstract away the pthread
implementation using cpp files is necessary so the synchronization
primitives were moved to a separate library.
2026-05-08 18:58:35 -05:00
R-Goc
1d8751363b LibCore: Use call_once from LibThreading
This commit makes ThreadEventQueue use call_once instead of
pthread_once_t. The aim is to limit the pthread dependency to
LibThreading.
2026-05-08 18:58:35 -05:00
Zaggy1024
d6ff027593 LibCore: Remove the pending jobs functionality from ThreadEventQueue
This is no longer used.
2026-03-02 17:06:39 -06:00
Zaggy1024
87c3053370 LibCore: Allow checking for a ThreadEventQueue without creating one 2025-12-31 10:41:51 +01:00
Andreas Kling
05e449d32a LibCore: Simplify how we calculate processed event count 2025-12-03 13:26:27 +01:00
Andreas Kling
25764fbc54 LibCore: Remove debug logging about pending promise count
This wasn't really achieving anything other than occasionally confusing
people into thinking our JS promise system was broken.
2025-12-03 13:26:27 +01:00
Andreas Kling
cebc4d00dd LibCore: Remove ability to post heap-allocated Core::Event objects
We no longer need this API since all clients have been converted to
simply posting the Core::Event::Type (or a callback function).
2025-12-03 13:26:27 +01:00
Andreas Kling
2a1c5dc108 LibCore: Don't require heap-allocated event to hold deferred invocation
Instead of creating a DeferredInvocationEvent every time we
deferred_invoke, we now let the QueuedEvent store the invokee Function
object directly.
2025-12-03 13:26:27 +01:00
Andreas Kling
69515f8c85 LibCore: Allow posting stateless events without heap-allocated Event
This patch adds an API for posting a Core::Event::Type to the thread
event queue without requiring a full Core::Event object.

We use this API to avoid heap allocations for every timer and notifier
activation event.
2025-12-03 13:26:27 +01:00
Andreas Kling
23fb9781d1 LibCore: Avoid excessive ref-count churn in event dispatch
We were strongly reffing the event receiver twice before actually
invoking the event handlers.
2025-12-03 13:26:27 +01:00
Andreas Kling
fa85f62895 LibCore: Remove unused Core::Event::Type::Quit 2025-12-03 13:26:27 +01:00
Zaggy1024
b572ae95a9 LibCore+LibWeb: Remove the dummy EventReceiver from deferred_invoke()
The DeferredInvocationContext only existed to satisfy the requirement
in ThreadEventQueue that each event has an EventReceiver. However,
deferred_invoke() was not even using the EventReceiver to call its
callback. Therefore, we don't need to allocate one for every deferred
invocation.

This also prevents WeakPtr::strong_ref() from racing and leaking the
context object when invoking a function across threads.
2025-12-02 21:21:03 -06:00
Andreas Kling
8c809fa5ee LibCore: Don't reserve 2 KiB of stack memory when processing event queue
The inline capacity on ThreadEventQueue::Private::queued_events caused
us to reserve (and importantly, not initialize!) 2 KiB of stack memory
when entering ThreadEventQueue::process().

This was causing any leftover pointers to GC-allocated objects within
that memory range to keep those objects alive, even when all other
references were gone.
2024-11-10 19:12:59 +01:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00