ublk-cpp v0.1
A ublk library for std::execution.
Loading...
Searching...
No Matches
handler.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
9#include "ublk/ublk_cmd.h"
10#include <concepts>
11#include <condy.hpp>
12#include <cstddef>
13#include <cstdint>
14
15namespace ublk {
16
20struct IoData {
22 uint16_t q_id;
24 uint16_t tag;
26 const ublksrv_io_desc *iod;
28 void *buf;
29};
30
32template <typename T>
33concept IoHandler = requires(T &t, const IoData &io_data) {
34 { t.handle_io(io_data) } noexcept -> detail::ex::sender;
35};
36
38template <typename T>
39concept QueueHandler = requires(T &t, uint16_t q_id) {
40 { t.init_queue(q_id) } noexcept -> detail::ex::sender;
41 { t.destroy_queue(q_id) } noexcept -> std::same_as<void>;
42};
43
46template <typename T>
47concept ShmHandler = requires(T &t, int32_t index, void *base, size_t size) {
48 { t.handle_reg_shm(index, base, size) } noexcept -> detail::ex::sender;
49 { t.handle_unreg_shm(index) } noexcept -> std::same_as<void>;
50};
51
52} // namespace ublk
Concept of an async handler with handle_io(const IoData&).
Definition handler.hpp:33
Concept of a handler with per-queue init/destroy callbacks.
Definition handler.hpp:39
Concept of a handler notified of shared memory buffer registration.
Definition handler.hpp:47
The std::execution backend namespace used by ublk-cpp.
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:20
uint16_t tag
Tag of the request.
Definition handler.hpp:24
void * buf
Buffer for the request data.
Definition handler.hpp:28
const ublksrv_io_desc * iod
I/O descriptor of the request in shared memory.
Definition handler.hpp:26
uint16_t q_id
Queue ID of the request.
Definition handler.hpp:22