Commit graph

24 commits

Author SHA1 Message Date
ayeteadoe
4cb7743915 LibCore: Expose register_process and implement for Windows event loop
This is the closest Windows equivalent to integrating process exit
handlers into the event loop.

Linux could also integrate register_process() into the poll() based
Unix event loop via the SYS_pidfd_open syscall; however, macOS requires
a kqueue. So for now register_process will only be used by Windows to
implement WebView::ProcessMonitor.

Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
2026-04-12 16:08:07 +02:00
Zaggy1024
d6ff027593 LibCore: Remove the pending jobs functionality from ThreadEventQueue
This is no longer used.
2026-03-02 17:06:39 -06:00
R-Goc
919f44f3a5 LibCore: Explicitly export symbols from LibCore
This patch adds explicit symbol export to LibCore. This leads to about
350 less symbols being exported.
2026-02-26 18:31:57 +01:00
Ben Wiederhake
a929850fdb LibCore: Remove unused header in EventLoop 2026-02-21 19:27:35 +01:00
Andreas Kling
e87f889e31 Everywhere: Abandon Swift adoption
After making no progress on this for a very long time, let's acknowledge
it's not going anywhere and remove it from the codebase.
2026-02-17 10:48:09 -05:00
Andreas Kling
9ad9c65368 Revert "LibCore: Add thread-safe weak deferred_invoke()"
This reverts commit 96ce468b60.

Appears to have regressed WPT.
2026-01-25 12:20:39 +01:00
Andreas Kling
96ce468b60 LibCore: Add thread-safe weak deferred_invoke()
Add a thread-safe deferred_invoke() API on WeakEventLoopReference that
queues work onto the owning thread's event queue and wakes that thread
via EventLoopManager hooks. This avoids calling wake() from foreign
threads during teardown.

Implement current_thread_handle()/wake_thread() in each backend and
track per-thread data so handles are validated before waking:

- Unix: wake via per-thread wake pipe
- Windows: wake via thread wake event
- macOS: wake via stored CFRunLoopRef
- Qt: wake via event target or QEventLoop::wakeUp()
- Android: wake via stored ALooper
2026-01-25 09:32:51 +01:00
Zaggy1024
2a5a9d2103 LibCore: Add a thread-safe weak link for EventLoop
Since the event loop has a very specifically scoped lifetime, we can't
ensure that it outlives threads that hold a reference to it without
blocking the thread that owns it. In order to make threads use the
event loop safely, we now have an atomically ref-counted
WeakEventLoopReference class that can be passed off to threads to
safely post events/callbacks to it.

Another possibility was to use an RWLock per event loop that each
thread holds a read lock on, while ~EventLoop() uses a write lock to
block and prevent it being destroyed until all its threads exit.
However, media data providers don't receive a signal to exit due to the
GC heap being intentionally leaked, so the process never actually
exits. It would be possible to specifically drop the reference to
PlaybackManager in HTMLMediaElement in order to make those data
providers die on their own, but that doesn't help prevent this problem
in other cases where it may arise.
2025-12-09 16:12:40 -06: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
c47e253c60 LibCore: Remove unused "visible for timer purposes" concept
This was a long-unused leftover from SerenityOS.
2025-08-11 16:55:25 +02:00
Andrew Kaster
b50d03f42e LibCore+LibWebView: Restore was_exit_requested to EventLoop
This method was removed in e015a43b51

However, it was not exactly *unused* as the commit message would say.
This method was the only thing that allowed spin_until to exit when
the event loop was cancelled. This happens normally when IPC connections
are closed, but also when the process is killed.

The logic to properly handle process exit from event loop spins needs to
actually notify the caller that their goal condition was not met though.
That will be handled in a later commit.
2025-04-30 11:12:23 -04:00
Andrew Kaster
c8787e6a9f LibCore: Add swift bindings for EventLoop as an Executor and Actor 2025-03-15 21:51:22 -06:00
Lucas CHOLLET
e015a43b51 LibCore: Remove unused methods from EventLoop 2025-01-30 15:34:02 -07:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Tom
21e6f5176c LibCore: Harden signal handling code to be called in global destrcutors
Move some more complex globals into a Singleton, which allows it being
used from global destructors. It solves problems where some global
variables, such as HashMaps may already be deleted, triggering crashes
trying to use them.
2021-01-09 21:12:31 +01:00
Tom
8548ec357c LibCore: Allow adding/removing signal handlers while handling signals
This allows adding and removing of asynchronous signal handlers while
executing signal handlers, even if it is for the same signal that is
being handled right now.
2021-01-09 21:12:31 +01:00
AnotherTest
c3dbe77024 LibCore: Add 'notify_forked()' to tear down the eventloop in forked child
This makes the forked process capable of constructing a new event loop,
should it choose to.
2020-09-09 20:35:21 +02:00
Tom
6751d03ea7 LibCore: Add register_signal and unregister_signal to EventLoop
This allows safer asynchronous handling of signals. Signals are
dispatched with highest priority.
2020-07-09 21:58:07 +02:00
Sergey Bugaev
8afcf0d87a LibCore: Do not assert that we can start the RPC server
Now that the Shell uses Core::EventLoop, we can't afford to just crash if /tmp
is unwritable.
2020-05-29 07:53:30 +02:00
Sergey Bugaev
345fbd1fc1 LibCore: Fix timer expiration processing
The previous code did not account for the case when there are timers present,
but none are enabled, and used a zero polling timeout.

Fixes https://github.com/SerenityOS/serenity/issues/2222
2020-05-15 17:41:54 +02:00
Andreas Kling
0e3a9d8e9d LibCore: Reduce header dependencies of EventLoop 2020-02-15 02:09:00 +01:00
Andreas Kling
8f7333f080 LibCore: Add a forward declaration header
This patch adds <LibCore/Forward.h> and uses it in various places to
shrink the header dependency graph.
2020-02-14 23:31:18 +01:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00
Renamed from Libraries/LibCore/CEventLoop.h (Browse further)