Condy v1.1.0
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
runtime_options.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <cstddef>
8#include <cstdint>
9#include <optional>
10#include <stdexcept>
11
12namespace condy {
13
14class Runtime;
15
23public:
24 using Self = RuntimeOptions;
25
32 Self &event_interval(size_t v) {
33 event_interval_ = v;
34 return *this;
35 }
36
44 disable_register_ring_fd_ = true;
45 return *this;
46 }
47
52 Self &enable_iopoll(bool hybrid = false) {
53 enable_iopoll_ = true;
54 enable_hybrid_iopoll_ = hybrid;
55 return *this;
56 }
57
63 Self &enable_sqpoll(size_t idle_time_ms = 1000,
64 std::optional<uint32_t> cpu = std::nullopt) {
65 if (enable_defer_taskrun_ || enable_coop_taskrun_) {
66 throw std::logic_error(
67 "sqpoll cannot be enabled with defer_taskrun or coop_taskrun");
68 }
69 enable_sqpoll_ = true;
70 sqpoll_idle_time_ms_ = idle_time_ms;
71 sqpoll_thread_cpu_ = cpu;
72 return *this;
73 }
74
79 if (enable_sqpoll_ || enable_coop_taskrun_) {
80 throw std::logic_error(
81 "defer_taskrun cannot be enabled with sqpoll or coop_taskrun");
82 }
83 enable_defer_taskrun_ = true;
84 return *this;
85 }
86
91 Self &sq_size(size_t v) {
92 sq_size_ = v;
93 return *this;
94 }
95
100 Self &cq_size(size_t v) {
101 cq_size_ = v;
102 return *this;
103 }
104
111 Self &enable_attach_wq(Runtime &other) {
112 attach_wq_target_ = &other;
113 return *this;
114 }
115
121 Self &enable_coop_taskrun(bool taskrun_flag = false) {
122 if (enable_sqpoll_ || enable_defer_taskrun_) {
123 throw std::logic_error(
124 "coop_taskrun cannot be enabled with sqpoll or defer_taskrun");
125 }
126 enable_coop_taskrun_ = true;
127 enable_coop_taskrun_flag_ = taskrun_flag;
128 return *this;
129 }
130
135 enable_sqe128_ = true;
136 return *this;
137 }
138
142 Self &enable_cqe32() {
143 enable_cqe32_ = true;
144 return *this;
145 }
146
152 Self &enable_no_mmap(void *buf = nullptr, size_t buf_size = 0) {
153 enable_no_mmap_ = true;
154 no_mmap_buf_ = buf;
155 no_mmap_buf_size_ = buf_size;
156 return *this;
157 }
158
159protected:
160 size_t event_interval_ = 61;
161 bool disable_register_ring_fd_ = false;
162 bool enable_iopoll_ = false;
163 bool enable_hybrid_iopoll_ = false;
164 bool enable_sqpoll_ = false;
165 size_t sqpoll_idle_time_ms_ = 1000;
166 std::optional<uint32_t> sqpoll_thread_cpu_ = std::nullopt;
167 bool enable_defer_taskrun_ = false;
168 size_t sq_size_ = 128;
169 size_t cq_size_ = 0; // 0 means default
170 Runtime *attach_wq_target_ = nullptr;
171 bool enable_coop_taskrun_ = false;
172 bool enable_coop_taskrun_flag_ = false;
173 bool enable_sqe128_ = false;
174 bool enable_cqe32_ = false;
175 bool enable_no_mmap_ = false;
176 void *no_mmap_buf_ = nullptr;
177 size_t no_mmap_buf_size_ = 0;
178
179 friend class Runtime;
180};
181
182} // namespace condy
The event loop runtime for executing asynchronous.
Definition runtime.hpp:76
The main namespace for the Condy library.
Definition condy.hpp:28
Runtime options.
Definition runtime_options.hpp:22
Self & enable_sqe128()
See IORING_SETUP_SQE128.
Definition runtime_options.hpp:134
Self & enable_coop_taskrun(bool taskrun_flag=false)
See IORING_SETUP_COOP_TASKRUN.
Definition runtime_options.hpp:121
Self & enable_attach_wq(Runtime &other)
See IORING_SETUP_ATTACH_WQ.
Definition runtime_options.hpp:111
Self & sq_size(size_t v)
Set SQ size.
Definition runtime_options.hpp:91
Self & enable_no_mmap(void *buf=nullptr, size_t buf_size=0)
See IORING_SETUP_NO_MMAP.
Definition runtime_options.hpp:152
Self & enable_iopoll(bool hybrid=false)
See IORING_SETUP_IOPOLL.
Definition runtime_options.hpp:52
Self & cq_size(size_t v)
Set CQ size.
Definition runtime_options.hpp:100
Self & disable_register_ring_fd()
Disable register ring fd.
Definition runtime_options.hpp:43
Self & enable_cqe32()
See IORING_SETUP_CQE32.
Definition runtime_options.hpp:142
Self & event_interval(size_t v)
Set event interval.
Definition runtime_options.hpp:32
Self & enable_sqpoll(size_t idle_time_ms=1000, std::optional< uint32_t > cpu=std::nullopt)
See IORING_SETUP_SQPOLL.
Definition runtime_options.hpp:63
Self & enable_defer_taskrun()
See IORING_SETUP_DEFER_TASKRUN.
Definition runtime_options.hpp:78