Commit Graph

22 Commits

Author SHA1 Message Date
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
Andreas Kling
e5933ec739 LibCore: Only deliver Read/Write events to listening notifiers
If a notifier has disabled read/write notifications via its event mask,
we should not spam it with events, even if they have a hook callback.
2020-07-06 23:17:10 +02:00
AnotherTest
6f7ac5d2e2 LibCore: Stop select()'ing after an interrupt if a quit was requested
This allows signal handlers to request the loop to terminate.
2020-07-05 15:43:14 +02:00
Matthew Olsson
e8e728454c AK: JsonParser improvements
- Parsing invalid JSON no longer asserts
    Instead of asserting when coming across malformed JSON,
    JsonParser::parse now returns an Optional<JsonValue>.
- Disallow trailing commas in JSON objects and arrays
- No longer parse 'undefined', as that is a purely JS thing
- No longer allow non-whitespace after anything consumed by the initial
  parse() call. Examples of things that were valid and no longer are:
    - undefineddfz
    - {"foo": 1}abcd
    - [1,2,3]4
- JsonObject.for_each_member now iterates in original insertion order
2020-06-13 12:43:22 +02:00
Andreas Kling
59adccb987 LibCore: Put some annoying debug spam behind EVENTLOOP_DEBUG 2020-06-02 12:46:52 +02:00
Sergey Bugaev
ec4902d1dd LibCore+Inspector: Move RPC sockets to /tmp/rpc
We have a hierarchical filesystem, let's make use of it :^)
2020-05-29 07:53:30 +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
Andreas Kling
c3379e3734 LibCore: Always wait_for_events() when pumping the event loop
This fixes an issue where continuously posting new events to the queue
would keep the event loop saturated, causing it to ignore notifiers.

Since notifiers are part of the big select(), we always have to call
wait_for_events() even if there are pending events. We're already smart
enough to select() without a timeout if we already have pending events.
2020-05-16 22:06:33 +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
Sergey Bugaev
b319aca81a LibCore: Do not assert that NonnullRefPtr is non-null
Clang complains about this; with the change the next commit is going
to make to ASSERT() internals, GCC is going to start to complain as well.
2020-04-30 11:30:27 +02:00
Andreas Kling
eeec1c1293 LibCore: Don't replay last handled event when leaving nested event loop
The event that triggered the exit from an inner event loop would always
get re-delivered in the outer event loop due to a silly off-by-one
mistake when transferring pending events between loops.
2020-04-03 22:55:48 +02:00
Liav A
7268499c76 LibCore: Use monotonic time when handling timers 2020-03-19 15:48:00 +01:00
Alex Muscar
81c6f72134
EventLoop: Don't destroy ID allocator (#1403)
The ID allocator is destroyed before a timer in HackStudio is
is unregistered leading to an access violation.

Fixes #1382.
2020-03-10 11:31:37 +01:00
Andreas Kling
b1058b33fb AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)
Use this instead of uintptr_t throughout the codebase. This makes it
possible to pass a FlatPtr to something that has u32 and u64 overloads.
2020-03-08 13:06:51 +01:00
Andreas Kling
42f2696355 LibCore: Add a way to set an individual Core::Object property remotely 2020-03-05 15:50:22 +01:00
Andreas Kling
d16f8214d8 LibCore: Allow RPC clients to specify the currently inspected object
Add a SetInspectedObject call that tells us which Core::Object a remote
client is currently looking it. Objects get notified when they gain
their first inspector, and when they lose their last one.
2020-03-05 14:40:47 +01:00
Andreas Kling
ceec1a7d38 AK: Make Vector use size_t for its size and capacity 2020-02-25 14:52:35 +01:00
Andreas Kling
88b9fcb976 AK: Use size_t for ByteBuffer sizes
This matches what we already do for string types.
2020-02-20 13:20:34 +01: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
258d798b34 LibCore: Merge the CSyscallUtils namespace into Core 2020-02-06 15:04:57 +01:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00