summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/Event.h
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-08-30 10:43:28 +0000
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-09-02 03:47:47 +0430
commite9121f8b1f9d31f0da89f34eac69a7da9f2901a0 (patch)
tree5e7087354e3a34b0f8494c60a16dfd64d5221a77 /Userland/Libraries/LibCore/Event.h
parentac24842f4895c9b7b46b217617407841cca2334f (diff)
downloadserenity-e9121f8b1f9d31f0da89f34eac69a7da9f2901a0.zip
LibCore+Userland: Implement Core::deferred_invoke
Core::deferred_invoke is a way of executing an action after previously queued events have been processed. It removes the requirement of having/being a Core::Object subclass in order to defer invocation through Core::Object::deferred_invoke. Core::Object::deferred_invoke now delegates to Core::deferred_invoke. The version with the Object& argument is still present but will be removed in the following commits. This commit additionally fixes a new places where the DeferredInvocationEvent was dispatched to the event loop directly, and replaces them with the Core::deferred_invoke equivalent.
Diffstat (limited to 'Userland/Libraries/LibCore/Event.h')
-rw-r--r--Userland/Libraries/LibCore/Event.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCore/Event.h b/Userland/Libraries/LibCore/Event.h
index 4de780a5f9..bc7045704b 100644
--- a/Userland/Libraries/LibCore/Event.h
+++ b/Userland/Libraries/LibCore/Event.h
@@ -10,6 +10,7 @@
#include <AK/String.h>
#include <AK/Types.h>
#include <AK/WeakPtr.h>
+#include <LibCore/DeferredInvocationContext.h>
#include <LibCore/Forward.h>
namespace Core {
@@ -50,14 +51,16 @@ class DeferredInvocationEvent : public Event {
friend class EventLoop;
public:
- DeferredInvocationEvent(Function<void(Object&)> invokee)
+ DeferredInvocationEvent(NonnullRefPtr<DeferredInvocationContext> context, Function<void()> invokee)
: Event(Event::Type::DeferredInvoke)
+ , m_context(move(context))
, m_invokee(move(invokee))
{
}
private:
- Function<void(Object&)> m_invokee;
+ NonnullRefPtr<DeferredInvocationContext> m_context;
+ Function<void()> m_invokee;
};
class TimerEvent final : public Event {