5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 // Disable autolinking for unit tests.
12 #if !defined(BOOST_ALL_NO_LIB)
13 #define BOOST_ALL_NO_LIB 1
14 #endif // !defined(BOOST_ALL_NO_LIB)
16 // Test that header file is self-contained.
17 #include <boost/asio/execution/any_executor.hpp>
20 #include <boost/asio/thread_pool.hpp>
21 #include "../unit_test.hpp"
23 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
24 # include <boost/bind/bind.hpp>
25 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
26 # include <functional>
27 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
29 using namespace boost::asio
;
31 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
32 namespace bindns
= boost
;
33 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
34 namespace bindns
= std
;
42 std::memset(data_
, 0, sizeof(data_
));
46 void execute(const F
&) const
50 std::size_t query(execution::occupancy_t
) const
55 friend bool operator==(const fat_executor
& a
,
56 const fat_executor
& b
) BOOST_ASIO_NOEXCEPT
58 return a
.id_
== b
.id_
;
61 friend bool operator!=(const fat_executor
& a
,
62 const fat_executor
& b
) BOOST_ASIO_NOEXCEPT
64 return a
.id_
!= b
.id_
;
68 unsigned char data_
[1024];
75 #if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
78 struct execute_member
<fat_executor
, F
>
80 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid
= true);
81 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept
= true);
82 typedef void result_type
;
85 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
87 #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
90 struct query_member
<fat_executor
, execution::occupancy_t
>
92 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid
= true);
93 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept
= false);
94 typedef std::size_t result_type
;
97 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
99 #if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
102 struct equality_comparable
<fat_executor
>
104 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid
= true);
105 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept
= true);
108 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
110 } // namespace traits
114 void increment(int* count
)
119 void any_executor_construction_test()
121 typedef execution::any_executor
<> ex_no_props_t
;
123 typedef execution::any_executor
<
124 execution::blocking_t
127 typedef execution::any_executor
<
128 execution::blocking_t
,
129 execution::occupancy_t
133 boost::asio::nullptr_t null_ptr
= boost::asio::nullptr_t();
135 ex_two_props_t ex_two_props_1
;
137 BOOST_ASIO_CHECK(ex_two_props_1
.target
<void>() == 0);
138 BOOST_ASIO_CHECK(ex_two_props_1
== null_ptr
);
140 ex_two_props_t
ex_two_props_2(null_ptr
);
142 BOOST_ASIO_CHECK(ex_two_props_2
.target
<void>() == 0);
143 BOOST_ASIO_CHECK(ex_two_props_2
== null_ptr
);
144 BOOST_ASIO_CHECK(ex_two_props_2
== ex_two_props_1
);
146 ex_two_props_t
ex_two_props_3(pool
.executor());
148 BOOST_ASIO_CHECK(ex_two_props_3
.target
<void>() != 0);
149 BOOST_ASIO_CHECK(ex_two_props_3
!= null_ptr
);
150 BOOST_ASIO_CHECK(ex_two_props_3
!= ex_two_props_1
);
152 ex_two_props_t
ex_two_props_4(ex_two_props_1
);
154 BOOST_ASIO_CHECK(ex_two_props_4
.target
<void>() == 0);
155 BOOST_ASIO_CHECK(ex_two_props_4
== null_ptr
);
156 BOOST_ASIO_CHECK(ex_two_props_4
== ex_two_props_1
);
158 ex_two_props_t
ex_two_props_5(ex_two_props_3
);
160 BOOST_ASIO_CHECK(ex_two_props_5
.target
<void>() != 0);
161 BOOST_ASIO_CHECK(ex_two_props_5
!= null_ptr
);
162 BOOST_ASIO_CHECK(ex_two_props_5
== ex_two_props_3
);
164 ex_two_props_t ex_two_props_6
= fat_executor(1);
166 BOOST_ASIO_CHECK(ex_two_props_6
.target
<void>() != 0);
167 BOOST_ASIO_CHECK(ex_two_props_6
!= null_ptr
);
168 BOOST_ASIO_CHECK(ex_two_props_6
!= ex_two_props_1
);
170 ex_two_props_t ex_two_props_7
= fat_executor(1);
172 BOOST_ASIO_CHECK(ex_two_props_7
.target
<void>() != 0);
173 BOOST_ASIO_CHECK(ex_two_props_7
!= null_ptr
);
174 BOOST_ASIO_CHECK(ex_two_props_7
!= ex_two_props_1
);
175 BOOST_ASIO_CHECK(ex_two_props_7
== ex_two_props_6
);
177 ex_two_props_t ex_two_props_8
= fat_executor(2);
179 BOOST_ASIO_CHECK(ex_two_props_8
.target
<void>() != 0);
180 BOOST_ASIO_CHECK(ex_two_props_8
!= null_ptr
);
181 BOOST_ASIO_CHECK(ex_two_props_8
!= ex_two_props_1
);
182 BOOST_ASIO_CHECK(ex_two_props_8
!= ex_two_props_6
);
183 BOOST_ASIO_CHECK(ex_two_props_8
!= ex_two_props_7
);
185 ex_two_props_t
ex_two_props_9(ex_two_props_6
);
187 BOOST_ASIO_CHECK(ex_two_props_9
.target
<void>() != 0);
188 BOOST_ASIO_CHECK(ex_two_props_9
!= null_ptr
);
189 BOOST_ASIO_CHECK(ex_two_props_9
!= ex_two_props_1
);
190 BOOST_ASIO_CHECK(ex_two_props_9
== ex_two_props_6
);
191 BOOST_ASIO_CHECK(ex_two_props_9
== ex_two_props_7
);
192 BOOST_ASIO_CHECK(ex_two_props_9
!= ex_two_props_8
);
194 #if defined(BOOST_ASIO_HAS_MOVE)
195 ex_two_props_t
ex_two_props_10(std::move(ex_two_props_1
));
197 BOOST_ASIO_CHECK(ex_two_props_10
.target
<void>() == 0);
198 BOOST_ASIO_CHECK(ex_two_props_10
== null_ptr
);
199 BOOST_ASIO_CHECK(ex_two_props_1
.target
<void>() == 0);
200 BOOST_ASIO_CHECK(ex_two_props_1
== null_ptr
);
202 ex_two_props_t
ex_two_props_11(std::move(ex_two_props_3
));
204 BOOST_ASIO_CHECK(ex_two_props_11
.target
<void>() != 0);
205 BOOST_ASIO_CHECK(ex_two_props_11
!= null_ptr
);
206 BOOST_ASIO_CHECK(ex_two_props_3
.target
<void>() == 0);
207 BOOST_ASIO_CHECK(ex_two_props_3
== null_ptr
);
208 BOOST_ASIO_CHECK(ex_two_props_11
== ex_two_props_5
);
210 ex_two_props_t
ex_two_props_12(std::move(ex_two_props_7
));
212 BOOST_ASIO_CHECK(ex_two_props_12
.target
<void>() != 0);
213 BOOST_ASIO_CHECK(ex_two_props_12
!= null_ptr
);
214 BOOST_ASIO_CHECK(ex_two_props_7
.target
<void>() == 0);
215 BOOST_ASIO_CHECK(ex_two_props_7
== null_ptr
);
216 BOOST_ASIO_CHECK(ex_two_props_12
== ex_two_props_6
);
217 BOOST_ASIO_CHECK(ex_two_props_12
!= ex_two_props_8
);
218 #endif // defined(BOOST_ASIO_HAS_MOVE)
220 ex_one_prop_t ex_one_prop_1
;
222 BOOST_ASIO_CHECK(ex_one_prop_1
.target
<void>() == 0);
223 BOOST_ASIO_CHECK(ex_one_prop_1
== null_ptr
);
225 ex_one_prop_t
ex_one_prop_2(null_ptr
);
227 BOOST_ASIO_CHECK(ex_one_prop_2
.target
<void>() == 0);
228 BOOST_ASIO_CHECK(ex_one_prop_2
== null_ptr
);
229 BOOST_ASIO_CHECK(ex_one_prop_2
== ex_one_prop_1
);
231 ex_one_prop_t
ex_one_prop_3(pool
.executor());
233 BOOST_ASIO_CHECK(ex_one_prop_3
.target
<void>() != 0);
234 BOOST_ASIO_CHECK(ex_one_prop_3
!= null_ptr
);
235 BOOST_ASIO_CHECK(ex_one_prop_3
!= ex_one_prop_1
);
237 ex_one_prop_t
ex_one_prop_4(ex_one_prop_1
);
239 BOOST_ASIO_CHECK(ex_one_prop_4
.target
<void>() == 0);
240 BOOST_ASIO_CHECK(ex_one_prop_4
== null_ptr
);
241 BOOST_ASIO_CHECK(ex_one_prop_4
== ex_one_prop_1
);
243 ex_one_prop_t
ex_one_prop_5(ex_one_prop_3
);
245 BOOST_ASIO_CHECK(ex_one_prop_5
.target
<void>() != 0);
246 BOOST_ASIO_CHECK(ex_one_prop_5
!= null_ptr
);
247 BOOST_ASIO_CHECK(ex_one_prop_5
== ex_one_prop_3
);
249 ex_one_prop_t ex_one_prop_6
= fat_executor(1);
251 BOOST_ASIO_CHECK(ex_one_prop_6
.target
<void>() != 0);
252 BOOST_ASIO_CHECK(ex_one_prop_6
!= null_ptr
);
253 BOOST_ASIO_CHECK(ex_one_prop_6
!= ex_one_prop_1
);
255 ex_one_prop_t ex_one_prop_7
= fat_executor(1);
257 BOOST_ASIO_CHECK(ex_one_prop_7
.target
<void>() != 0);
258 BOOST_ASIO_CHECK(ex_one_prop_7
!= null_ptr
);
259 BOOST_ASIO_CHECK(ex_one_prop_7
!= ex_one_prop_1
);
260 BOOST_ASIO_CHECK(ex_one_prop_7
== ex_one_prop_6
);
262 ex_one_prop_t ex_one_prop_8
= fat_executor(2);
264 BOOST_ASIO_CHECK(ex_one_prop_8
.target
<void>() != 0);
265 BOOST_ASIO_CHECK(ex_one_prop_8
!= null_ptr
);
266 BOOST_ASIO_CHECK(ex_one_prop_8
!= ex_one_prop_1
);
267 BOOST_ASIO_CHECK(ex_one_prop_8
!= ex_one_prop_6
);
268 BOOST_ASIO_CHECK(ex_one_prop_8
!= ex_one_prop_7
);
270 ex_one_prop_t
ex_one_prop_9(ex_one_prop_6
);
272 BOOST_ASIO_CHECK(ex_one_prop_9
.target
<void>() != 0);
273 BOOST_ASIO_CHECK(ex_one_prop_9
!= null_ptr
);
274 BOOST_ASIO_CHECK(ex_one_prop_9
!= ex_one_prop_1
);
275 BOOST_ASIO_CHECK(ex_one_prop_9
== ex_one_prop_6
);
276 BOOST_ASIO_CHECK(ex_one_prop_9
== ex_one_prop_7
);
277 BOOST_ASIO_CHECK(ex_one_prop_9
!= ex_one_prop_8
);
279 #if defined(BOOST_ASIO_HAS_MOVE)
280 ex_one_prop_t
ex_one_prop_10(std::move(ex_one_prop_1
));
282 BOOST_ASIO_CHECK(ex_one_prop_10
.target
<void>() == 0);
283 BOOST_ASIO_CHECK(ex_one_prop_10
== null_ptr
);
284 BOOST_ASIO_CHECK(ex_one_prop_1
.target
<void>() == 0);
285 BOOST_ASIO_CHECK(ex_one_prop_1
== null_ptr
);
287 ex_one_prop_t
ex_one_prop_11(std::move(ex_one_prop_3
));
289 BOOST_ASIO_CHECK(ex_one_prop_11
.target
<void>() != 0);
290 BOOST_ASIO_CHECK(ex_one_prop_11
!= null_ptr
);
291 BOOST_ASIO_CHECK(ex_one_prop_3
.target
<void>() == 0);
292 BOOST_ASIO_CHECK(ex_one_prop_3
== null_ptr
);
293 BOOST_ASIO_CHECK(ex_one_prop_11
== ex_one_prop_5
);
295 ex_one_prop_t
ex_one_prop_12(std::move(ex_one_prop_7
));
297 BOOST_ASIO_CHECK(ex_one_prop_12
.target
<void>() != 0);
298 BOOST_ASIO_CHECK(ex_one_prop_12
!= null_ptr
);
299 BOOST_ASIO_CHECK(ex_one_prop_7
.target
<void>() == 0);
300 BOOST_ASIO_CHECK(ex_one_prop_7
== null_ptr
);
301 BOOST_ASIO_CHECK(ex_one_prop_12
== ex_one_prop_6
);
302 BOOST_ASIO_CHECK(ex_one_prop_12
!= ex_one_prop_8
);
303 #endif // defined(BOOST_ASIO_HAS_MOVE)
305 ex_one_prop_t
ex_one_prop_13(ex_two_props_1
);
307 BOOST_ASIO_CHECK(ex_one_prop_13
.target
<void>() == 0);
308 BOOST_ASIO_CHECK(ex_one_prop_13
== null_ptr
);
310 ex_one_prop_t
ex_one_prop_14(ex_two_props_5
);
312 BOOST_ASIO_CHECK(ex_one_prop_14
.target
<void>() != 0);
313 BOOST_ASIO_CHECK(ex_one_prop_14
!= null_ptr
);
315 ex_one_prop_t
ex_one_prop_15(ex_two_props_9
);
317 BOOST_ASIO_CHECK(ex_one_prop_15
.target
<void>() != 0);
318 BOOST_ASIO_CHECK(ex_one_prop_15
!= null_ptr
);
320 ex_no_props_t ex_no_props_1
;
322 BOOST_ASIO_CHECK(ex_no_props_1
.target
<void>() == 0);
323 BOOST_ASIO_CHECK(ex_no_props_1
== null_ptr
);
325 ex_no_props_t
ex_no_props_2(null_ptr
);
327 BOOST_ASIO_CHECK(ex_no_props_2
.target
<void>() == 0);
328 BOOST_ASIO_CHECK(ex_no_props_2
== null_ptr
);
329 BOOST_ASIO_CHECK(ex_no_props_2
== ex_no_props_1
);
331 ex_no_props_t
ex_no_props_3(pool
.executor());
333 BOOST_ASIO_CHECK(ex_no_props_3
.target
<void>() != 0);
334 BOOST_ASIO_CHECK(ex_no_props_3
!= null_ptr
);
335 BOOST_ASIO_CHECK(ex_no_props_3
!= ex_no_props_1
);
337 ex_no_props_t
ex_no_props_4(ex_no_props_1
);
339 BOOST_ASIO_CHECK(ex_no_props_4
.target
<void>() == 0);
340 BOOST_ASIO_CHECK(ex_no_props_4
== null_ptr
);
341 BOOST_ASIO_CHECK(ex_no_props_4
== ex_no_props_1
);
343 ex_no_props_t
ex_no_props_5(ex_no_props_3
);
345 BOOST_ASIO_CHECK(ex_no_props_5
.target
<void>() != 0);
346 BOOST_ASIO_CHECK(ex_no_props_5
!= null_ptr
);
347 BOOST_ASIO_CHECK(ex_no_props_5
== ex_no_props_3
);
349 ex_no_props_t ex_no_props_6
= fat_executor(1);
351 BOOST_ASIO_CHECK(ex_no_props_6
.target
<void>() != 0);
352 BOOST_ASIO_CHECK(ex_no_props_6
!= null_ptr
);
353 BOOST_ASIO_CHECK(ex_no_props_6
!= ex_no_props_1
);
355 ex_no_props_t ex_no_props_7
= fat_executor(1);
357 BOOST_ASIO_CHECK(ex_no_props_7
.target
<void>() != 0);
358 BOOST_ASIO_CHECK(ex_no_props_7
!= null_ptr
);
359 BOOST_ASIO_CHECK(ex_no_props_7
!= ex_no_props_1
);
360 BOOST_ASIO_CHECK(ex_no_props_7
== ex_no_props_6
);
362 ex_no_props_t ex_no_props_8
= fat_executor(2);
364 BOOST_ASIO_CHECK(ex_no_props_8
.target
<void>() != 0);
365 BOOST_ASIO_CHECK(ex_no_props_8
!= null_ptr
);
366 BOOST_ASIO_CHECK(ex_no_props_8
!= ex_no_props_1
);
367 BOOST_ASIO_CHECK(ex_no_props_8
!= ex_no_props_6
);
368 BOOST_ASIO_CHECK(ex_no_props_8
!= ex_no_props_7
);
370 ex_no_props_t
ex_no_props_9(ex_no_props_6
);
372 BOOST_ASIO_CHECK(ex_no_props_9
.target
<void>() != 0);
373 BOOST_ASIO_CHECK(ex_no_props_9
!= null_ptr
);
374 BOOST_ASIO_CHECK(ex_no_props_9
!= ex_no_props_1
);
375 BOOST_ASIO_CHECK(ex_no_props_9
== ex_no_props_6
);
376 BOOST_ASIO_CHECK(ex_no_props_9
== ex_no_props_7
);
377 BOOST_ASIO_CHECK(ex_no_props_9
!= ex_no_props_8
);
379 #if defined(BOOST_ASIO_HAS_MOVE)
380 ex_no_props_t
ex_no_props_10(std::move(ex_no_props_1
));
382 BOOST_ASIO_CHECK(ex_no_props_10
.target
<void>() == 0);
383 BOOST_ASIO_CHECK(ex_no_props_10
== null_ptr
);
384 BOOST_ASIO_CHECK(ex_no_props_1
.target
<void>() == 0);
385 BOOST_ASIO_CHECK(ex_no_props_1
== null_ptr
);
387 ex_no_props_t
ex_no_props_11(std::move(ex_no_props_3
));
389 BOOST_ASIO_CHECK(ex_no_props_11
.target
<void>() != 0);
390 BOOST_ASIO_CHECK(ex_no_props_11
!= null_ptr
);
391 BOOST_ASIO_CHECK(ex_no_props_3
.target
<void>() == 0);
392 BOOST_ASIO_CHECK(ex_no_props_3
== null_ptr
);
393 BOOST_ASIO_CHECK(ex_no_props_11
== ex_no_props_5
);
395 ex_no_props_t
ex_no_props_12(std::move(ex_no_props_7
));
397 BOOST_ASIO_CHECK(ex_no_props_12
.target
<void>() != 0);
398 BOOST_ASIO_CHECK(ex_no_props_12
!= null_ptr
);
399 BOOST_ASIO_CHECK(ex_no_props_7
.target
<void>() == 0);
400 BOOST_ASIO_CHECK(ex_no_props_7
== null_ptr
);
401 BOOST_ASIO_CHECK(ex_no_props_12
== ex_no_props_6
);
402 BOOST_ASIO_CHECK(ex_no_props_12
!= ex_no_props_8
);
403 #endif // defined(BOOST_ASIO_HAS_MOVE)
405 ex_no_props_t
ex_no_props_13(ex_two_props_1
);
407 BOOST_ASIO_CHECK(ex_no_props_13
.target
<void>() == 0);
408 BOOST_ASIO_CHECK(ex_no_props_13
== null_ptr
);
410 ex_no_props_t
ex_no_props_14(ex_two_props_5
);
412 BOOST_ASIO_CHECK(ex_no_props_14
.target
<void>() != 0);
413 BOOST_ASIO_CHECK(ex_no_props_14
!= null_ptr
);
415 ex_no_props_t
ex_no_props_15(ex_two_props_9
);
417 BOOST_ASIO_CHECK(ex_no_props_15
.target
<void>() != 0);
418 BOOST_ASIO_CHECK(ex_no_props_15
!= null_ptr
);
420 ex_no_props_t
ex_no_props_16(ex_one_prop_1
);
422 BOOST_ASIO_CHECK(ex_no_props_16
.target
<void>() == 0);
423 BOOST_ASIO_CHECK(ex_no_props_16
== null_ptr
);
425 ex_no_props_t
ex_no_props_17(ex_one_prop_5
);
427 BOOST_ASIO_CHECK(ex_no_props_17
.target
<void>() != 0);
428 BOOST_ASIO_CHECK(ex_no_props_17
!= null_ptr
);
430 ex_no_props_t
ex_no_props_18(ex_one_prop_9
);
432 BOOST_ASIO_CHECK(ex_no_props_18
.target
<void>() != 0);
433 BOOST_ASIO_CHECK(ex_no_props_18
!= null_ptr
);
436 void any_executor_assignment_test()
438 typedef execution::any_executor
<> ex_no_props_t
;
440 typedef execution::any_executor
<
441 execution::blocking_t
444 typedef execution::any_executor
<
445 execution::blocking_t
,
446 execution::occupancy_t
450 boost::asio::nullptr_t null_ptr
= boost::asio::nullptr_t();
452 ex_two_props_t ex_two_props_1
;
454 ex_two_props_t ex_two_props_2
;
455 ex_two_props_2
= null_ptr
;
457 BOOST_ASIO_CHECK(ex_two_props_2
.target
<void>() == 0);
459 ex_two_props_t ex_two_props_3
;
460 ex_two_props_3
= pool
.executor();
462 BOOST_ASIO_CHECK(ex_two_props_3
.target
<void>() != 0);
464 ex_two_props_t ex_two_props_4
;
465 ex_two_props_4
= ex_two_props_1
;
467 BOOST_ASIO_CHECK(ex_two_props_4
.target
<void>() == 0);
468 BOOST_ASIO_CHECK(ex_two_props_4
== ex_two_props_1
);
470 ex_two_props_4
= ex_two_props_3
;
472 BOOST_ASIO_CHECK(ex_two_props_4
.target
<void>() != 0);
473 BOOST_ASIO_CHECK(ex_two_props_4
== ex_two_props_3
);
475 ex_two_props_t ex_two_props_5
;
476 ex_two_props_5
= fat_executor(1);
478 BOOST_ASIO_CHECK(ex_two_props_5
.target
<void>() != 0);
479 BOOST_ASIO_CHECK(ex_two_props_5
!= null_ptr
);
480 BOOST_ASIO_CHECK(ex_two_props_5
!= ex_two_props_1
);
482 ex_two_props_t ex_two_props_6
;
483 ex_two_props_6
= fat_executor(1);
485 BOOST_ASIO_CHECK(ex_two_props_6
.target
<void>() != 0);
486 BOOST_ASIO_CHECK(ex_two_props_6
!= null_ptr
);
487 BOOST_ASIO_CHECK(ex_two_props_6
!= ex_two_props_1
);
488 BOOST_ASIO_CHECK(ex_two_props_6
== ex_two_props_5
);
490 ex_two_props_6
= fat_executor(2);
492 BOOST_ASIO_CHECK(ex_two_props_6
.target
<void>() != 0);
493 BOOST_ASIO_CHECK(ex_two_props_6
!= null_ptr
);
494 BOOST_ASIO_CHECK(ex_two_props_6
!= ex_two_props_1
);
495 BOOST_ASIO_CHECK(ex_two_props_6
!= ex_two_props_5
);
497 ex_two_props_t ex_two_props_7
;
498 ex_two_props_7
= ex_two_props_5
;
500 BOOST_ASIO_CHECK(ex_two_props_7
.target
<void>() != 0);
501 BOOST_ASIO_CHECK(ex_two_props_7
!= null_ptr
);
502 BOOST_ASIO_CHECK(ex_two_props_7
!= ex_two_props_1
);
503 BOOST_ASIO_CHECK(ex_two_props_7
== ex_two_props_5
);
504 BOOST_ASIO_CHECK(ex_two_props_7
!= ex_two_props_6
);
506 #if defined(BOOST_ASIO_HAS_MOVE)
507 ex_two_props_t ex_two_props_8
;
508 ex_two_props_8
= std::move(ex_two_props_1
);
510 BOOST_ASIO_CHECK(ex_two_props_8
.target
<void>() == 0);
511 BOOST_ASIO_CHECK(ex_two_props_1
.target
<void>() == 0);
513 ex_two_props_8
= std::move(ex_two_props_3
);
515 BOOST_ASIO_CHECK(ex_two_props_8
.target
<void>() != 0);
516 BOOST_ASIO_CHECK(ex_two_props_3
.target
<void>() == 0);
517 BOOST_ASIO_CHECK(ex_two_props_8
== ex_two_props_4
);
519 ex_two_props_8
= std::move(ex_two_props_5
);
521 BOOST_ASIO_CHECK(ex_two_props_8
.target
<void>() != 0);
522 BOOST_ASIO_CHECK(ex_two_props_5
.target
<void>() == 0);
523 BOOST_ASIO_CHECK(ex_two_props_8
== ex_two_props_7
);
524 #endif // defined(BOOST_ASIO_HAS_MOVE)
526 ex_one_prop_t ex_one_prop_1
;
528 ex_one_prop_t ex_one_prop_2
;
529 ex_one_prop_2
= null_ptr
;
531 BOOST_ASIO_CHECK(ex_one_prop_2
.target
<void>() == 0);
533 ex_one_prop_t ex_one_prop_3
;
534 ex_one_prop_3
= pool
.executor();
536 BOOST_ASIO_CHECK(ex_one_prop_3
.target
<void>() != 0);
538 ex_one_prop_t ex_one_prop_4
;
539 ex_one_prop_4
= ex_one_prop_1
;
541 BOOST_ASIO_CHECK(ex_one_prop_4
.target
<void>() == 0);
542 BOOST_ASIO_CHECK(ex_one_prop_4
== ex_one_prop_1
);
544 ex_one_prop_4
= ex_one_prop_3
;
546 BOOST_ASIO_CHECK(ex_one_prop_4
.target
<void>() != 0);
547 BOOST_ASIO_CHECK(ex_one_prop_4
== ex_one_prop_3
);
549 ex_one_prop_t ex_one_prop_5
;
550 ex_one_prop_5
= fat_executor(1);
552 BOOST_ASIO_CHECK(ex_one_prop_5
.target
<void>() != 0);
553 BOOST_ASIO_CHECK(ex_one_prop_5
!= null_ptr
);
554 BOOST_ASIO_CHECK(ex_one_prop_5
!= ex_one_prop_1
);
556 ex_one_prop_t ex_one_prop_6
;
557 ex_one_prop_6
= fat_executor(1);
559 BOOST_ASIO_CHECK(ex_one_prop_6
.target
<void>() != 0);
560 BOOST_ASIO_CHECK(ex_one_prop_6
!= null_ptr
);
561 BOOST_ASIO_CHECK(ex_one_prop_6
!= ex_one_prop_1
);
562 BOOST_ASIO_CHECK(ex_one_prop_6
== ex_one_prop_5
);
564 ex_one_prop_6
= fat_executor(2);
566 BOOST_ASIO_CHECK(ex_one_prop_6
.target
<void>() != 0);
567 BOOST_ASIO_CHECK(ex_one_prop_6
!= null_ptr
);
568 BOOST_ASIO_CHECK(ex_one_prop_6
!= ex_one_prop_1
);
569 BOOST_ASIO_CHECK(ex_one_prop_6
!= ex_one_prop_5
);
571 ex_one_prop_t ex_one_prop_7
;
572 ex_one_prop_7
= ex_one_prop_5
;
574 BOOST_ASIO_CHECK(ex_one_prop_7
.target
<void>() != 0);
575 BOOST_ASIO_CHECK(ex_one_prop_7
!= null_ptr
);
576 BOOST_ASIO_CHECK(ex_one_prop_7
!= ex_one_prop_1
);
577 BOOST_ASIO_CHECK(ex_one_prop_7
== ex_one_prop_5
);
578 BOOST_ASIO_CHECK(ex_one_prop_7
!= ex_one_prop_6
);
580 #if defined(BOOST_ASIO_HAS_MOVE)
581 ex_one_prop_t ex_one_prop_8
;
582 ex_one_prop_8
= std::move(ex_one_prop_1
);
584 BOOST_ASIO_CHECK(ex_one_prop_8
.target
<void>() == 0);
585 BOOST_ASIO_CHECK(ex_one_prop_1
.target
<void>() == 0);
587 ex_one_prop_8
= std::move(ex_one_prop_3
);
589 BOOST_ASIO_CHECK(ex_one_prop_8
.target
<void>() != 0);
590 BOOST_ASIO_CHECK(ex_one_prop_3
.target
<void>() == 0);
591 BOOST_ASIO_CHECK(ex_one_prop_8
== ex_one_prop_4
);
593 ex_one_prop_8
= std::move(ex_one_prop_5
);
595 BOOST_ASIO_CHECK(ex_one_prop_8
.target
<void>() != 0);
596 BOOST_ASIO_CHECK(ex_one_prop_5
.target
<void>() == 0);
597 BOOST_ASIO_CHECK(ex_one_prop_8
== ex_one_prop_7
);
598 #endif // defined(BOOST_ASIO_HAS_MOVE)
600 ex_one_prop_t ex_one_prop_9
;
601 ex_one_prop_9
= ex_two_props_1
;
603 BOOST_ASIO_CHECK(ex_one_prop_9
.target
<void>() == 0);
605 ex_one_prop_9
= ex_two_props_4
;
607 BOOST_ASIO_CHECK(ex_one_prop_9
.target
<void>() != 0);
609 ex_one_prop_9
= ex_two_props_7
;
611 BOOST_ASIO_CHECK(ex_one_prop_9
.target
<void>() != 0);
613 ex_no_props_t ex_no_props_1
;
615 ex_no_props_t ex_no_props_2
;
616 ex_no_props_2
= null_ptr
;
618 BOOST_ASIO_CHECK(ex_no_props_2
.target
<void>() == 0);
620 ex_no_props_t ex_no_props_3
;
621 ex_no_props_3
= pool
.executor();
623 BOOST_ASIO_CHECK(ex_no_props_3
.target
<void>() != 0);
625 ex_no_props_t ex_no_props_4
;
626 ex_no_props_4
= ex_no_props_1
;
628 BOOST_ASIO_CHECK(ex_no_props_4
.target
<void>() == 0);
629 BOOST_ASIO_CHECK(ex_no_props_4
== ex_no_props_1
);
631 ex_no_props_4
= ex_no_props_3
;
633 BOOST_ASIO_CHECK(ex_no_props_4
.target
<void>() != 0);
634 BOOST_ASIO_CHECK(ex_no_props_4
== ex_no_props_3
);
636 ex_no_props_t ex_no_props_5
;
637 ex_no_props_5
= fat_executor(1);
639 BOOST_ASIO_CHECK(ex_no_props_5
.target
<void>() != 0);
640 BOOST_ASIO_CHECK(ex_no_props_5
!= null_ptr
);
641 BOOST_ASIO_CHECK(ex_no_props_5
!= ex_no_props_1
);
643 ex_no_props_t ex_no_props_6
;
644 ex_no_props_6
= fat_executor(1);
646 BOOST_ASIO_CHECK(ex_no_props_6
.target
<void>() != 0);
647 BOOST_ASIO_CHECK(ex_no_props_6
!= null_ptr
);
648 BOOST_ASIO_CHECK(ex_no_props_6
!= ex_no_props_1
);
649 BOOST_ASIO_CHECK(ex_no_props_6
== ex_no_props_5
);
651 ex_no_props_6
= fat_executor(2);
653 BOOST_ASIO_CHECK(ex_no_props_6
.target
<void>() != 0);
654 BOOST_ASIO_CHECK(ex_no_props_6
!= null_ptr
);
655 BOOST_ASIO_CHECK(ex_no_props_6
!= ex_no_props_1
);
656 BOOST_ASIO_CHECK(ex_no_props_6
!= ex_no_props_5
);
658 ex_no_props_t ex_no_props_7
;
659 ex_no_props_7
= ex_no_props_5
;
661 BOOST_ASIO_CHECK(ex_no_props_7
.target
<void>() != 0);
662 BOOST_ASIO_CHECK(ex_no_props_7
!= null_ptr
);
663 BOOST_ASIO_CHECK(ex_no_props_7
!= ex_no_props_1
);
664 BOOST_ASIO_CHECK(ex_no_props_7
== ex_no_props_5
);
665 BOOST_ASIO_CHECK(ex_no_props_7
!= ex_no_props_6
);
667 #if defined(BOOST_ASIO_HAS_MOVE)
668 ex_no_props_t ex_no_props_8
;
669 ex_no_props_8
= std::move(ex_no_props_1
);
671 BOOST_ASIO_CHECK(ex_no_props_8
.target
<void>() == 0);
672 BOOST_ASIO_CHECK(ex_no_props_1
.target
<void>() == 0);
674 ex_no_props_8
= std::move(ex_no_props_3
);
676 BOOST_ASIO_CHECK(ex_no_props_8
.target
<void>() != 0);
677 BOOST_ASIO_CHECK(ex_no_props_3
.target
<void>() == 0);
678 BOOST_ASIO_CHECK(ex_no_props_8
== ex_no_props_4
);
680 ex_no_props_8
= std::move(ex_no_props_5
);
682 BOOST_ASIO_CHECK(ex_no_props_8
.target
<void>() != 0);
683 BOOST_ASIO_CHECK(ex_no_props_5
.target
<void>() == 0);
684 BOOST_ASIO_CHECK(ex_no_props_8
== ex_no_props_7
);
685 #endif // defined(BOOST_ASIO_HAS_MOVE)
687 ex_no_props_t ex_no_props_9
;
688 ex_no_props_9
= ex_two_props_1
;
690 BOOST_ASIO_CHECK(ex_no_props_9
.target
<void>() == 0);
692 ex_no_props_9
= ex_two_props_4
;
694 BOOST_ASIO_CHECK(ex_no_props_9
.target
<void>() != 0);
696 ex_no_props_9
= ex_two_props_7
;
698 BOOST_ASIO_CHECK(ex_no_props_9
.target
<void>() != 0);
700 ex_no_props_9
= ex_one_prop_1
;
702 BOOST_ASIO_CHECK(ex_no_props_9
.target
<void>() == 0);
704 ex_no_props_9
= ex_one_prop_4
;
706 BOOST_ASIO_CHECK(ex_no_props_9
.target
<void>() != 0);
708 ex_no_props_9
= ex_one_prop_7
;
710 BOOST_ASIO_CHECK(ex_no_props_9
.target
<void>() != 0);
713 void any_executor_swap_test()
715 typedef execution::any_executor
<> ex_no_props_t
;
717 typedef execution::any_executor
<
718 execution::blocking_t
721 typedef execution::any_executor
<
722 execution::blocking_t
,
723 execution::occupancy_t
726 thread_pool
pool1(1);
727 thread_pool
pool2(1);
729 ex_no_props_t
ex_no_props_1(pool1
.executor());
730 ex_no_props_t
ex_no_props_2(pool2
.executor());
732 ex_no_props_t
ex_no_props_3(ex_no_props_1
);
733 ex_no_props_t
ex_no_props_4(ex_no_props_2
);
735 BOOST_ASIO_CHECK(ex_no_props_3
== ex_no_props_1
);
736 BOOST_ASIO_CHECK(ex_no_props_4
== ex_no_props_2
);
738 ex_no_props_3
.swap(ex_no_props_4
);
740 BOOST_ASIO_CHECK(ex_no_props_3
== ex_no_props_2
);
741 BOOST_ASIO_CHECK(ex_no_props_4
== ex_no_props_1
);
743 execution::swap(ex_no_props_3
, ex_no_props_4
);
745 BOOST_ASIO_CHECK(ex_no_props_3
== ex_no_props_1
);
746 BOOST_ASIO_CHECK(ex_no_props_4
== ex_no_props_2
);
748 ex_one_prop_t
ex_one_prop_1(pool1
.executor());
749 ex_one_prop_t
ex_one_prop_2(pool2
.executor());
751 ex_one_prop_t
ex_one_prop_3(ex_one_prop_1
);
752 ex_one_prop_t
ex_one_prop_4(ex_one_prop_2
);
754 BOOST_ASIO_CHECK(ex_one_prop_3
== ex_one_prop_1
);
755 BOOST_ASIO_CHECK(ex_one_prop_4
== ex_one_prop_2
);
757 ex_one_prop_3
.swap(ex_one_prop_4
);
759 BOOST_ASIO_CHECK(ex_one_prop_3
== ex_one_prop_2
);
760 BOOST_ASIO_CHECK(ex_one_prop_4
== ex_one_prop_1
);
762 execution::swap(ex_one_prop_3
, ex_one_prop_4
);
764 BOOST_ASIO_CHECK(ex_one_prop_3
== ex_one_prop_1
);
765 BOOST_ASIO_CHECK(ex_one_prop_4
== ex_one_prop_2
);
767 ex_two_props_t
ex_two_props_1(pool1
.executor());
768 ex_two_props_t
ex_two_props_2(pool2
.executor());
770 ex_two_props_t
ex_two_props_3(ex_two_props_1
);
771 ex_two_props_t
ex_two_props_4(ex_two_props_2
);
773 BOOST_ASIO_CHECK(ex_two_props_3
== ex_two_props_1
);
774 BOOST_ASIO_CHECK(ex_two_props_4
== ex_two_props_2
);
776 ex_two_props_3
.swap(ex_two_props_4
);
778 BOOST_ASIO_CHECK(ex_two_props_3
== ex_two_props_2
);
779 BOOST_ASIO_CHECK(ex_two_props_4
== ex_two_props_1
);
781 execution::swap(ex_two_props_3
, ex_two_props_4
);
783 BOOST_ASIO_CHECK(ex_two_props_3
== ex_two_props_1
);
784 BOOST_ASIO_CHECK(ex_two_props_4
== ex_two_props_2
);
787 void any_executor_query_test()
790 execution::any_executor
<
791 execution::blocking_t
,
792 execution::outstanding_work_t
,
793 execution::relationship_t
,
794 execution::mapping_t::thread_t
,
795 execution::occupancy_t
>
799 boost::asio::query(ex
, boost::asio::execution::blocking
)
800 == boost::asio::execution::blocking
.possibly
);
803 boost::asio::query(ex
, boost::asio::execution::blocking
.possibly
)
804 == boost::asio::execution::blocking
.possibly
);
807 boost::asio::query(ex
, boost::asio::execution::outstanding_work
)
808 == boost::asio::execution::outstanding_work
.untracked
);
811 boost::asio::query(ex
, boost::asio::execution::outstanding_work
.untracked
)
812 == boost::asio::execution::outstanding_work
.untracked
);
815 boost::asio::query(ex
, boost::asio::execution::relationship
)
816 == boost::asio::execution::relationship
.fork
);
819 boost::asio::query(ex
, boost::asio::execution::relationship
.fork
)
820 == boost::asio::execution::relationship
.fork
);
823 boost::asio::query(ex
, boost::asio::execution::mapping
)
824 == boost::asio::execution::mapping
.thread
);
827 boost::asio::query(ex
, boost::asio::execution::occupancy
)
831 void any_executor_execute_test()
835 execution::any_executor
<
836 execution::blocking_t::possibly_t
,
837 execution::blocking_t::never_t
,
838 execution::outstanding_work_t::untracked_t
,
839 execution::outstanding_work_t::tracked_t
,
840 execution::relationship_t::continuation_t
>
843 boost::asio::execution::execute(pool
.executor(),
844 bindns::bind(increment
, &count
));
846 boost::asio::execution::execute(
847 boost::asio::require(pool
.executor(),
848 boost::asio::execution::blocking
.possibly
),
849 bindns::bind(increment
, &count
));
851 boost::asio::execution::execute(
852 boost::asio::require(pool
.executor(),
853 boost::asio::execution::blocking
.never
),
854 bindns::bind(increment
, &count
));
856 boost::asio::execution::execute(
857 boost::asio::require(pool
.executor(),
858 boost::asio::execution::blocking
.never
,
859 boost::asio::execution::outstanding_work
.tracked
),
860 bindns::bind(increment
, &count
));
862 boost::asio::execution::execute(
863 boost::asio::require(pool
.executor(),
864 boost::asio::execution::blocking
.never
,
865 boost::asio::execution::outstanding_work
.untracked
),
866 bindns::bind(increment
, &count
));
868 boost::asio::execution::execute(
869 boost::asio::require(pool
.executor(),
870 boost::asio::execution::blocking
.never
,
871 boost::asio::execution::outstanding_work
.untracked
,
872 boost::asio::execution::relationship
.continuation
),
873 bindns::bind(increment
, &count
));
877 BOOST_ASIO_CHECK(count
== 6);
880 BOOST_ASIO_TEST_SUITE
883 BOOST_ASIO_TEST_CASE(any_executor_construction_test
)
884 BOOST_ASIO_TEST_CASE(any_executor_assignment_test
)
885 BOOST_ASIO_TEST_CASE(any_executor_swap_test
)
886 BOOST_ASIO_TEST_CASE(any_executor_query_test
)
887 BOOST_ASIO_TEST_CASE(any_executor_execute_test
)