ladybird/Libraries/LibIPC
Andreas Kling 757795ada4 LibIPC: Move message decoding from main thread to I/O thread
Previously, IPC messages were decoded on the main thread:

1. I/O thread received raw bytes and file descriptors
2. I/O thread stored them in a queue and notified main thread
3. Main thread decoded bytes into Message objects
4. Main thread processed the messages

Now, decoding happens on the I/O thread:

1. I/O thread receives raw bytes and file descriptors
2. I/O thread decodes them using a configurable MessageDecoder
3. I/O thread calls MessageHandler which stores decoded messages
4. I/O thread signals condition variable (for sync waiters)
5. I/O thread wakes main event loop via deferred_invoke()
6. Main thread processes already-decoded messages

This is achieved by:

- Adding MessageDecoder and MessageHandler callbacks to TransportSocket
- Connection template sets up the decoder (tries both endpoints)
- ConnectionBase::initialize_messaging() sets up the handler
- Storing a WeakEventLoopReference to wake the main thread
- Using mutex + condition variable for thread-safe queue access
- Sync message waiting now uses the CV directly instead of polling

The raw message API (read_as_many_messages_as_possible_without_blocking)
is preserved for MessagePort which uses its own decoding logic.

This architecture prepares for future multi-thread dispatch where
different message types could be routed to different handler threads
(e.g., scrolling messages to a dedicated scroll thread).
2026-01-25 09:32:51 +01:00
..
AutoCloseFileDescriptor.cpp Everywhere: Remove LibCore/System.h includes from header files 2025-12-04 15:40:46 +00:00
AutoCloseFileDescriptor.h Everywhere: Remove LibCore/System.h includes from header files 2025-12-04 15:40:46 +00:00
CMakeLists.txt Everywhere: Remove LibCore/System.h includes from header files 2025-12-04 15:40:46 +00:00
Concepts.h LibIPC: Add a generic encoder for spans 2025-03-09 11:14:20 -04:00
Connection.cpp LibIPC: Move message decoding from main thread to I/O thread 2026-01-25 09:32:51 +01:00
Connection.h LibIPC: Move message decoding from main thread to I/O thread 2026-01-25 09:32:51 +01:00
ConnectionFromClient.h LibIPC: Simplify IPC read hook 2025-10-21 09:31:22 +02:00
ConnectionToServer.h Everywhere: Make TransportSocket non-movable 2025-04-09 15:27:52 +02:00
Decoder.cpp LibIPC: Don't apply decode size limit to AnonymousBuffer 2026-01-24 15:23:02 +01:00
Decoder.h LibIPC: Add additional validation for decoded values 2026-01-22 17:38:15 +01:00
Encoder.cpp LibIPC: Add VERIFY assertions to catch encoding bugs 2026-01-22 17:38:15 +01:00
Encoder.h AK+LibURL: Use AK::IPv4/6 in Host 2025-12-31 10:24:56 +01:00
File.cpp LibIPC: Use try_dequeue() when decoding IPC::File 2026-01-22 17:38:15 +01:00
File.h Everywhere: Remove LibCore/System.h includes from header files 2025-12-04 15:40:46 +00:00
FileWindows.cpp LibIPC: Add missing include and impl on win32 2025-12-05 07:07:52 -05:00
Forward.h LibIPC: Add some type aliases and MessageBuffer helpers 2025-07-18 10:09:02 -04:00
HandleType.h LibIPC: Port to Windows 2025-02-12 22:31:43 -07:00
Limits.h LibIPC: Move IPC message limits to a shared Limits.h header 2026-01-22 17:38:15 +01:00
Message.cpp LibIPC: VERIFY message limits when encoding outgoing messages 2026-01-22 17:38:15 +01:00
Message.h LibIPC: Add some type aliases and MessageBuffer helpers 2025-07-18 10:09:02 -04:00
MessageWindows.cpp LibIPC: Add missing include and impl on win32 2025-12-05 07:07:52 -05:00
MultiServer.h Everywhere: Make TransportSocket non-movable 2025-04-09 15:27:52 +02:00
SingleServer.h Everywhere: Remove LibCore/System.h includes from header files 2025-12-04 15:40:46 +00:00
Stub.h Meta: Enforce newlines around namespaces 2025-05-14 02:01:59 -06:00
Transport.h LibIPC: Port to Windows 2025-02-12 22:31:43 -07:00
TransportSocket.cpp LibIPC: Move message decoding from main thread to I/O thread 2026-01-25 09:32:51 +01:00
TransportSocket.h LibIPC: Move message decoding from main thread to I/O thread 2026-01-25 09:32:51 +01:00
TransportSocketWindows.cpp LibIPC: Move message decoding from main thread to I/O thread 2026-01-25 09:32:51 +01:00
TransportSocketWindows.h LibIPC: Move message decoding from main thread to I/O thread 2026-01-25 09:32:51 +01:00