Condy v1.8
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
cqe_handler.hpp
Go to the documentation of this file.
1
7
8#pragma once
9
10#include "condy/concepts.hpp"
12#include "condy/runtime.hpp"
13#include <cassert>
14#include <cerrno>
15#include <cstdint>
16#include <utility>
17
18namespace condy {
19
27 int32_t operator()(io_uring_cqe *cqe) noexcept { return cqe->res; }
28};
29
38template <typename Br>
39 requires(requires(Br *br, io_uring_cqe *cqe) { br->handle_finish(cqe); })
40class SelectBufferCQEHandler {
41public:
42 SelectBufferCQEHandler(Br *buffers) : buffers_(buffers) {}
43
44 auto operator()(io_uring_cqe *cqe) noexcept {
45 return std::make_pair(cqe->res, buffers_->handle_finish(cqe));
46 }
47
48private:
49 Br *buffers_;
50};
51
59 std::pair<int32_t, uint64_t> operator()(io_uring_cqe *cqe) noexcept {
60 assert(
61 detail::Context::current().runtime()->ring_internal().check_cqe32(
62 cqe) &&
63 "Expected big CQE for NVMe passthrough");
64 return {cqe->res, cqe->big_cqe[0]};
65 }
66};
67
68#if !IO_URING_CHECK_VERSION(2, 12) // >= 2.12
78 int tstype; // cqe->flags >> IORING_TIMESTAMP_TYPE_SHIFT
79
83 bool hwts; // cqe->flags & IORING_CQE_F_TSTAMP_HW
84
88 io_timespec ts; // *(io_timespec *)(cqe->big_cqe)
89};
90
98 std::pair<int32_t, TxTimestampResult>
99 operator()(io_uring_cqe *cqe) noexcept {
100 assert(
101 detail::Context::current().runtime()->ring_internal().check_cqe32(
102 cqe) &&
103 "Expected big CQE for TX timestamp operations");
104 TxTimestampResult result;
105 result.tstype =
106 static_cast<int>(cqe->flags >> IORING_TIMESTAMP_TYPE_SHIFT);
107 result.hwts = cqe->flags & IORING_CQE_F_TSTAMP_HW;
108 result.ts = reinterpret_cast<io_timespec &>(cqe->big_cqe);
109 return {cqe->res, result};
110 }
111};
112#endif
113
114} // namespace condy
The main namespace for the Condy library.
Definition condy.hpp:37
Runtime type for running the io_uring event loop.
A CQE handler for NVMe passthrough commands that extracts the status and result from the CQE.
A simple CQE handler that extracts the result from the CQE without any additional processing.
A CQE handler for TX timestamp operations that extracts timestamp information from the CQE.
Result for TX timestamp operations, containing timestamp information from the socket error queue.
int tstype
The timestamp type, could be SCM_TSTAMP_SND, SCM_TSTAMP_SCHED, SCM_TSTAMP_ACK, etc.
io_timespec ts
The timestamp value.
bool hwts
Whether this timestamp is a hardware timestamp.