mpd/src/event/UringManager.hxx
Max Kellermann 26577d1301 io/uring/Queue: make Submit() virtual, Push() not
This allows submitting io_uring calls without an `Operation` instance
(fire & forget).  We'll do that for close().
2023-05-22 21:57:18 +02:00

36 lines
680 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#pragma once
#include "PipeEvent.hxx"
#include "IdleEvent.hxx"
#include "io/uring/Queue.hxx"
namespace Uring {
class Manager final : public Queue {
PipeEvent event;
IdleEvent idle_event;
public:
explicit Manager(EventLoop &event_loop)
:Queue(1024, 0),
event(event_loop, BIND_THIS_METHOD(OnSocketReady),
GetFileDescriptor()),
idle_event(event_loop, BIND_THIS_METHOD(OnIdle))
{
event.ScheduleRead();
}
void Submit() override {
idle_event.Schedule();
}
private:
void OnSocketReady(unsigned flags) noexcept;
void OnIdle() noexcept;
};
} // namespace Uring