2
3
4
5
9#include <restinio/async_chain/common.hpp>
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
199
200
201
202
203
204 class actual_controller_t
final
213
214
215
216
223 const schedulers_array_t & schedulers )
240 if( index_to_use >= m_schedulers.size() )
246 return { m_schedulers[ index_to_use ] };
253
254
255
263 store_to( std::size_t index, Head && head, Tail && ...tail )
265 m_schedulers[ index ] =
266 [scheduler = std::move(head)]
267 ( unique_controller_t controller ) -> schedule_result_t
269 return scheduler( std::move(controller) );
272 if constexpr( 0u !=
sizeof...(tail) )
273 store_to( index + 1u, std::forward<Tail>(tail)... );
278
279
280
281
282
286
287
288
289
290
291
292 template<
typename... Schedulers >
295 static_assert( Size ==
sizeof...(schedulers),
296 "Wrong number of parameters for the constructor of "
297 "fixed_size_chain_t<Size>. Exact `Size` parameters expected" );
299 store_to( 0u, std::forward<Schedulers>(schedulers)... );
303
304
305
306
307
312 unique_controller_t controller =
313 std::make_unique< actual_controller_t >(
316 next( std::move(controller) );
Interface of a controller of an async chan.
std::size_t m_current
Index of the current scheduler to be used.
const actual_request_handle_t & request_handle() const noexcept override
Get reference to the source request.
actual_controller_t(actual_request_handle_t request, const schedulers_array_t &schedulers)
Initializing constructor.
const actual_request_handle_t m_request
The source request.
actual_on_next_result_t on_next() override
Command to try find a next scheduler to be invoked.
schedulers_array_t m_schedulers
Request handlers.
A holder of fixed-size chain of asynchronous handlers.
schedulers_array_t m_schedulers
The array of schedulers.
fixed_size_chain_t(Schedulers &&...schedulers)
Initializing constructor.
fixed_size_chain_t()=delete
request_handling_status_t operator()(const actual_request_handle_t &req) const
typename async_handling_controller_t< Extra_Data_Factory >::actual_on_next_result_t actual_on_next_result_t
Short alias for the result of controller's on_next method.
typename async_handling_controller_t< Extra_Data_Factory >::actual_request_handle_t actual_request_handle_t
Short alias to a smart pointer to the source request.
void store_to(std::size_t index, Head &&head, Tail &&...tail)
Helper method to initialize the array of schedulers.
constexpr request_handling_status_t request_accepted() noexcept
request_handling_status_t
Request handling status.
Special type to be used as an indicator that there are no more schedulers in an async chain.