Condy v1.3.0
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
cqe_handler.hpp
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "condy/concepts.hpp"
13#include <cerrno>
14#include <cstdint>
15#include <utility>
16
17namespace condy {
18
19class SimpleCQEHandler {
20public:
21 using ReturnType = int32_t;
22
23 void handle_cqe(io_uring_cqe *cqe) { res_ = cqe->res; }
24
25 ReturnType extract_result() { return res_; }
26
27private:
28 int32_t res_ = -ENOTRECOVERABLE; // Internal error if not set
29};
30
31template <BufferRingLike Br> class SelectBufferCQEHandler {
32public:
33 using ReturnType = std::pair<int, typename Br::ReturnType>;
34
35 SelectBufferCQEHandler(Br *buffers) : buffers_(buffers) {}
36
37 void handle_cqe(io_uring_cqe *cqe) {
38 res_ = cqe->res;
39 flags_ = cqe->flags;
40 }
41
42 ReturnType extract_result() {
43 return std::make_pair(res_, buffers_->handle_finish(res_, flags_));
44 }
45
46private:
47 int32_t res_ = -ENOTRECOVERABLE; // Internal error if not set
48 uint32_t flags_ = 0;
49 Br *buffers_;
50};
51
52} // namespace condy
The main namespace for the Condy library.
Definition condy.hpp:28