From f4d40c292bd8dd6ee9ac35c8b170965af962fdc5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 28 Jun 2024 12:06:31 +0200 Subject: [PATCH] LibIPC: Remove no-longer-used DeferredInvoker abstraction --- Userland/Libraries/LibIPC/Connection.cpp | 24 ++++-------------------- Userland/Libraries/LibIPC/Connection.h | 12 ------------ 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/Userland/Libraries/LibIPC/Connection.cpp b/Userland/Libraries/LibIPC/Connection.cpp index 6ae16408995..585e17ee675 100644 --- a/Userland/Libraries/LibIPC/Connection.cpp +++ b/Userland/Libraries/LibIPC/Connection.cpp @@ -9,33 +9,17 @@ #include #include #include -#include namespace IPC { -struct CoreEventLoopDeferredInvoker final : public DeferredInvoker { - virtual ~CoreEventLoopDeferredInvoker() = default; - - virtual void schedule(Function callback) override - { - Core::deferred_invoke(move(callback)); - } -}; - ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullOwnPtr socket, u32 local_endpoint_magic) : m_local_stub(local_stub) , m_socket(move(socket)) , m_local_endpoint_magic(local_endpoint_magic) - , m_deferred_invoker(make()) { m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); }); } -void ConnectionBase::set_deferred_invoker(NonnullOwnPtr deferred_invoker) -{ - m_deferred_invoker = move(deferred_invoker); -} - ErrorOr ConnectionBase::post_message(Message const& message) { return post_message(TRY(message.encode())); @@ -116,8 +100,8 @@ ErrorOr> ConnectionBase::read_as_much_as_possible_from_socket_without bool should_shut_down = false; auto schedule_shutdown = [this, &should_shut_down]() { should_shut_down = true; - m_deferred_invoker->schedule([strong_this = NonnullRefPtr(*this)] { - strong_this->shutdown(); + deferred_invoke([this] { + shutdown(); }); }; @@ -180,8 +164,8 @@ ErrorOr ConnectionBase::drain_messages_from_peer() } if (!m_unprocessed_messages.is_empty()) { - m_deferred_invoker->schedule([strong_this = NonnullRefPtr(*this)] { - strong_this->handle_messages(); + deferred_invoke([this] { + handle_messages(); }); } return {}; diff --git a/Userland/Libraries/LibIPC/Connection.h b/Userland/Libraries/LibIPC/Connection.h index 1387a09b04b..d412908f380 100644 --- a/Userland/Libraries/LibIPC/Connection.h +++ b/Userland/Libraries/LibIPC/Connection.h @@ -27,22 +27,12 @@ namespace IPC { -// NOTE: This is an abstraction to allow using IPC::Connection without a Core::EventLoop. -// FIXME: It's not particularly nice, think of something nicer. -struct DeferredInvoker { - virtual ~DeferredInvoker() = default; - virtual void schedule(Function) = 0; -}; - class ConnectionBase : public Core::EventReceiver { C_OBJECT_ABSTRACT(ConnectionBase); public: virtual ~ConnectionBase() override = default; - void set_deferred_invoker(NonnullOwnPtr); - DeferredInvoker& deferred_invoker() { return *m_deferred_invoker; } - bool is_open() const { return m_socket->is_open(); } ErrorOr post_message(Message const&); @@ -78,8 +68,6 @@ protected: ByteBuffer m_unprocessed_bytes; u32 m_local_endpoint_magic { 0 }; - - NonnullOwnPtr m_deferred_invoker; }; template