2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
2020-05-05 15:18:02 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-10-13 10:40:48 +02:00
|
|
|
#include "PipeEvent.hxx"
|
2020-10-14 13:34:15 +02:00
|
|
|
#include "IdleEvent.hxx"
|
2020-05-05 15:18:02 +02:00
|
|
|
#include "io/uring/Queue.hxx"
|
|
|
|
|
|
|
|
namespace Uring {
|
|
|
|
|
2020-10-14 14:24:16 +02:00
|
|
|
class Manager final : public Queue {
|
2021-10-13 10:40:48 +02:00
|
|
|
PipeEvent event;
|
2020-10-14 13:34:15 +02:00
|
|
|
IdleEvent idle_event;
|
|
|
|
|
2020-05-05 15:18:02 +02:00
|
|
|
public:
|
|
|
|
explicit Manager(EventLoop &event_loop)
|
|
|
|
:Queue(1024, 0),
|
2020-10-14 14:24:16 +02:00
|
|
|
event(event_loop, BIND_THIS_METHOD(OnSocketReady),
|
2021-10-13 10:40:48 +02:00
|
|
|
GetFileDescriptor()),
|
2020-10-14 13:34:15 +02:00
|
|
|
idle_event(event_loop, BIND_THIS_METHOD(OnIdle))
|
2020-05-05 15:18:02 +02:00
|
|
|
{
|
2020-10-14 14:24:16 +02:00
|
|
|
event.ScheduleRead();
|
2020-05-05 15:18:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Push(struct io_uring_sqe &sqe,
|
|
|
|
Operation &operation) noexcept override {
|
|
|
|
AddPending(sqe, operation);
|
2020-10-14 13:34:15 +02:00
|
|
|
idle_event.Schedule();
|
2020-05-05 15:18:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-10-14 14:24:16 +02:00
|
|
|
void OnSocketReady(unsigned flags) noexcept;
|
2020-10-14 13:34:15 +02:00
|
|
|
void OnIdle() noexcept;
|
2020-05-05 15:18:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Uring
|