ublk-cpp v0.0
Loading...
Searching...
No Matches
handler.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "ublk/ublk_cmd.h"
9#include <concepts>
10#include <condy.hpp>
11#include <cstddef>
12#include <cstdint>
13
14namespace ublk {
15
16namespace detail {
17namespace ex = condy::detail::ex;
18}
19
23struct IoData {
25 uint16_t q_id;
27 uint16_t tag;
29 const ublksrv_io_desc *iod;
31 void *buf;
32};
33
35template <typename T>
36concept IoHandler = requires(T &t, const IoData &io_data) {
37 { t.handle_io(io_data) } noexcept -> detail::ex::sender;
38};
39
41template <typename T>
42concept QueueHandler = requires(T &t, uint16_t q_id) {
43 { t.init_queue(q_id) } noexcept -> detail::ex::sender;
44 { t.destroy_queue(q_id) } noexcept -> std::same_as<void>;
45};
46
49template <typename T>
50concept ShmHandler = requires(T &t, int32_t index, void *base, size_t size) {
51 { t.handle_reg_shm(index, base, size) } noexcept -> detail::ex::sender;
52 { t.handle_unreg_shm(index) } noexcept -> std::same_as<void>;
53};
54
55} // namespace ublk
Concept of an async handler with handle_io(const IoData&).
Definition handler.hpp:36
Concept of a handler with per-queue init/destroy callbacks.
Definition handler.hpp:42
Concept of a handler notified of shared memory buffer registration.
Definition handler.hpp:50
The main namespace of the ublk-cpp library.
Definition ublk.hpp:21
Context of a single I/O request delivered to a handler.
Definition handler.hpp:23
uint16_t tag
Tag of the request.
Definition handler.hpp:27
void * buf
Buffer for the request data.
Definition handler.hpp:31
const ublksrv_io_desc * iod
I/O descriptor of the request in shared memory.
Definition handler.hpp:29
uint16_t q_id
Queue ID of the request.
Definition handler.hpp:25