LibIPC: Remove no-longer-used DeferredInvoker abstraction

This commit is contained in:
Andreas Kling 2024-06-28 12:06:31 +02:00 committed by Andreas Kling
parent 4db05ecf69
commit f4d40c292b
2 changed files with 4 additions and 32 deletions

View File

@ -9,33 +9,17 @@
#include <LibIPC/Connection.h>
#include <LibIPC/File.h>
#include <LibIPC/Stub.h>
#include <sys/select.h>
namespace IPC {
struct CoreEventLoopDeferredInvoker final : public DeferredInvoker {
virtual ~CoreEventLoopDeferredInvoker() = default;
virtual void schedule(Function<void()> callback) override
{
Core::deferred_invoke(move(callback));
}
};
ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullOwnPtr<Core::LocalSocket> 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<CoreEventLoopDeferredInvoker>())
{
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
}
void ConnectionBase::set_deferred_invoker(NonnullOwnPtr<DeferredInvoker> deferred_invoker)
{
m_deferred_invoker = move(deferred_invoker);
}
ErrorOr<void> ConnectionBase::post_message(Message const& message)
{
return post_message(TRY(message.encode()));
@ -116,8 +100,8 @@ ErrorOr<Vector<u8>> 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<void> 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 {};

View File

@ -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<void()>) = 0;
};
class ConnectionBase : public Core::EventReceiver {
C_OBJECT_ABSTRACT(ConnectionBase);
public:
virtual ~ConnectionBase() override = default;
void set_deferred_invoker(NonnullOwnPtr<DeferredInvoker>);
DeferredInvoker& deferred_invoker() { return *m_deferred_invoker; }
bool is_open() const { return m_socket->is_open(); }
ErrorOr<void> post_message(Message const&);
@ -78,8 +68,6 @@ protected:
ByteBuffer m_unprocessed_bytes;
u32 m_local_endpoint_magic { 0 };
NonnullOwnPtr<DeferredInvoker> m_deferred_invoker;
};
template<typename LocalEndpoint, typename PeerEndpoint>