join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
io_policy.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_CORE_IO_POLICY_HPP
26#define JOIN_CORE_IO_POLICY_HPP
27
28// C.
29#include <liburing.h>
30#include <cstdint>
31
32namespace join
33{
35 {
36 static constexpr uint32_t sqEntries = 1024;
37 static constexpr uint32_t flags = 0;
38 };
39
41 {
42 static constexpr uint32_t sqEntries = 1024;
43 static constexpr uint32_t flags = 0;
44 static constexpr uint32_t spin = 200;
45 };
46
48 {
49 static constexpr uint32_t sqEntries = 1024;
50 static constexpr uint32_t flags = IORING_SETUP_SQPOLL;
51 static constexpr uint32_t spin = 200;
52 static constexpr uint32_t sqThreadIdle = 2000;
53 static constexpr uint32_t sqThreadCpu = 0;
54 };
55
56 template <typename...>
57 using void_t = void;
58
59 template <typename T, typename = void>
60 struct has_spin : std::false_type
61 {
62 };
63
64 template <typename T>
65 struct has_spin<T, void_t<decltype (T::spin)>> : std::true_type
66 {
67 };
68
69 template <typename T, typename = void>
70 struct has_sqpoll : std::false_type
71 {
72 };
73
74 template <typename T>
75 struct has_sqpoll<T, void_t<decltype (T::flags)>>
76 : std::integral_constant<bool, bool (T::flags& IORING_SETUP_SQPOLL)>
77 {
78 };
79
80 template <typename T>
81 struct is_default : std::integral_constant<bool, !has_spin<T>::value && !has_sqpoll<T>::value>
82 {
83 };
84
85 template <typename T, typename = void>
86 struct has_cq_entries : std::false_type
87 {
88 };
89
90 template <typename T>
91 struct has_cq_entries<T, void_t<decltype (T::cqEntries)>> : std::true_type
92 {
93 };
94
95 template <typename T, typename = void>
96 struct has_sq_thread_idle : std::false_type
97 {
98 };
99
100 template <typename T>
101 struct has_sq_thread_idle<T, void_t<decltype (T::sqThreadIdle)>> : std::true_type
102 {
103 };
104
105 template <typename T, typename = void>
106 struct has_sq_thread_cpu : std::false_type
107 {
108 };
109
110 template <typename T>
111 struct has_sq_thread_cpu<T, void_t<decltype (T::sqThreadCpu)>> : std::true_type
112 {
113 };
114}
115
116#endif
Definition acceptor.hpp:32
void void_t
Definition io_policy.hpp:57
Definition error.hpp:137
Definition io_policy.hpp:35
static constexpr uint32_t sqEntries
Definition io_policy.hpp:36
static constexpr uint32_t flags
Definition io_policy.hpp:37
Definition io_policy.hpp:41
static constexpr uint32_t sqEntries
Definition io_policy.hpp:42
static constexpr uint32_t spin
Definition io_policy.hpp:44
static constexpr uint32_t flags
Definition io_policy.hpp:43
Definition io_policy.hpp:48
static constexpr uint32_t flags
Definition io_policy.hpp:50
static constexpr uint32_t sqEntries
Definition io_policy.hpp:49
static constexpr uint32_t spin
Definition io_policy.hpp:51
static constexpr uint32_t sqThreadCpu
Definition io_policy.hpp:53
static constexpr uint32_t sqThreadIdle
Definition io_policy.hpp:52
Definition io_policy.hpp:87
Definition io_policy.hpp:61
Definition io_policy.hpp:107
Definition io_policy.hpp:97
Definition io_policy.hpp:71
Definition io_policy.hpp:82