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 };
54
55 template <typename...>
56 using void_t = void;
57
58 template <typename T, typename = void>
59 struct has_spin : std::false_type
60 {
61 };
62
63 template <typename T>
64 struct has_spin<T, void_t<decltype (T::spin)>> : std::true_type
65 {
66 };
67
68 template <typename T, typename = void>
69 struct has_sqpoll : std::false_type
70 {
71 };
72
73 template <typename T>
74 struct has_sqpoll<T, void_t<decltype (T::flags)>>
75 : std::integral_constant<bool, bool (T::flags& IORING_SETUP_SQPOLL)>
76 {
77 };
78
79 template <typename T>
80 struct is_default : std::integral_constant<bool, !has_spin<T>::value && !has_sqpoll<T>::value>
81 {
82 };
83
84 template <typename T, typename = void>
85 struct has_cq_entries : std::false_type
86 {
87 };
88
89 template <typename T>
90 struct has_cq_entries<T, void_t<decltype (T::cqEntries)>> : std::true_type
91 {
92 };
93
94 template <typename T, typename = void>
95 struct has_sq_thread_idle : std::false_type
96 {
97 };
98
99 template <typename T>
100 struct has_sq_thread_idle<T, void_t<decltype (T::sqThreadIdle)>> : std::true_type
101 {
102 };
103
104 template <typename T, typename = void>
105 struct has_sq_thread_cpu : std::false_type
106 {
107 };
108
109 template <typename T>
110 struct has_sq_thread_cpu<T, void_t<decltype (T::sqThreadCpu)>> : std::true_type
111 {
112 };
113}
114
115#endif
Definition acceptor.hpp:32
void void_t
Definition io_policy.hpp:56
Definition error.hpp:144
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 sqThreadIdle
Definition io_policy.hpp:52
Definition io_policy.hpp:86
Definition io_policy.hpp:60
Definition io_policy.hpp:106
Definition io_policy.hpp:96
Definition io_policy.hpp:70
Definition io_policy.hpp:81