Clementine
io_context.hpp
1 //
2 // io_context.hpp
3 // ~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10 
11 #ifndef ASIO_IO_CONTEXT_HPP
12 #define ASIO_IO_CONTEXT_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 #include <cstddef>
20 #include <stdexcept>
21 #include <typeinfo>
22 #include "asio/async_result.hpp"
23 #include "asio/detail/wrapped_handler.hpp"
24 #include "asio/error_code.hpp"
25 #include "asio/execution.hpp"
26 #include "asio/execution_context.hpp"
27 
28 #if defined(ASIO_HAS_CHRONO)
29 # include "asio/detail/chrono.hpp"
30 #endif // defined(ASIO_HAS_CHRONO)
31 
32 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
33 # include "asio/detail/winsock_init.hpp"
34 #elif defined(__sun) || defined(__QNX__) || defined(__hpux) || defined(_AIX) \
35  || defined(__osf__)
36 # include "asio/detail/signal_init.hpp"
37 #endif
38 
39 #if defined(ASIO_HAS_IOCP)
40 # include "asio/detail/win_iocp_io_context.hpp"
41 #else
42 # include "asio/detail/scheduler.hpp"
43 #endif
44 
45 #include "asio/detail/push_options.hpp"
46 
47 namespace asio {
48 
49 namespace detail {
50 #if defined(ASIO_HAS_IOCP)
51  typedef win_iocp_io_context io_context_impl;
52  class win_iocp_overlapped_ptr;
53 #else
54  typedef scheduler io_context_impl;
55 #endif
56 
58  {
59  ASIO_STATIC_CONSTEXPR(unsigned int, blocking_never = 1);
60  ASIO_STATIC_CONSTEXPR(unsigned int, relationship_continuation = 2);
61  ASIO_STATIC_CONSTEXPR(unsigned int, outstanding_work_tracked = 4);
62  };
63 } // namespace detail
64 
66 
212  : public execution_context
213 {
214 private:
216 #if defined(ASIO_HAS_IOCP)
217  friend class detail::win_iocp_overlapped_ptr;
218 #endif
219 
220 public:
221  template <typename Allocator, unsigned int Bits>
223 
224  template <typename Allocator, unsigned int Bits>
225  friend class basic_executor_type;
226 
229 
230 #if !defined(ASIO_NO_DEPRECATED)
231  class work;
232  friend class work;
233 #endif // !defined(ASIO_NO_DEPRECATED)
234 
235  class service;
236 
237 #if !defined(ASIO_NO_EXTENSIONS) \
238  && !defined(ASIO_NO_TS_EXECUTORS)
239  class strand;
240 #endif // !defined(ASIO_NO_EXTENSIONS)
241  // && !defined(ASIO_NO_TS_EXECUTORS)
242 
244  typedef std::size_t count_type;
245 
247  ASIO_DECL io_context();
248 
250 
256  ASIO_DECL explicit io_context(int concurrency_hint);
257 
259 
290  ASIO_DECL ~io_context();
291 
293  executor_type get_executor() ASIO_NOEXCEPT;
294 
296 
320  ASIO_DECL count_type run();
321 
322 #if !defined(ASIO_NO_DEPRECATED)
323 
351  ASIO_DECL count_type run(asio::error_code& ec);
352 #endif // !defined(ASIO_NO_DEPRECATED)
353 
354 #if defined(ASIO_HAS_CHRONO) || defined(GENERATING_DOCUMENTATION)
355 
366  template <typename Rep, typename Period>
367  std::size_t run_for(const chrono::duration<Rep, Period>& rel_time);
368 
370 
379  template <typename Clock, typename Duration>
380  std::size_t run_until(const chrono::time_point<Clock, Duration>& abs_time);
381 #endif // defined(ASIO_HAS_CHRONO) || defined(GENERATING_DOCUMENTATION)
382 
385 
400  ASIO_DECL count_type run_one();
401 
402 #if !defined(ASIO_NO_DEPRECATED)
403 
422  ASIO_DECL count_type run_one(asio::error_code& ec);
423 #endif // !defined(ASIO_NO_DEPRECATED)
424 
425 #if defined(ASIO_HAS_CHRONO) || defined(GENERATING_DOCUMENTATION)
426 
437  template <typename Rep, typename Period>
438  std::size_t run_one_for(const chrono::duration<Rep, Period>& rel_time);
439 
442 
451  template <typename Clock, typename Duration>
452  std::size_t run_one_until(
453  const chrono::time_point<Clock, Duration>& abs_time);
454 #endif // defined(ASIO_HAS_CHRONO) || defined(GENERATING_DOCUMENTATION)
455 
458 
464  ASIO_DECL count_type poll();
465 
466 #if !defined(ASIO_NO_DEPRECATED)
467 
477  ASIO_DECL count_type poll(asio::error_code& ec);
478 #endif // !defined(ASIO_NO_DEPRECATED)
479 
482 
488  ASIO_DECL count_type poll_one();
489 
490 #if !defined(ASIO_NO_DEPRECATED)
491 
501  ASIO_DECL count_type poll_one(asio::error_code& ec);
502 #endif // !defined(ASIO_NO_DEPRECATED)
503 
505 
511  ASIO_DECL void stop();
512 
514 
523  ASIO_DECL bool stopped() const;
524 
526 
536  ASIO_DECL void restart();
537 
538 #if !defined(ASIO_NO_DEPRECATED)
539 
551  void reset();
552 
555 
575  template <typename LegacyCompletionHandler>
576  ASIO_INITFN_AUTO_RESULT_TYPE(LegacyCompletionHandler, void ())
577  dispatch(ASIO_MOVE_ARG(LegacyCompletionHandler) handler);
578 
581 
602  template <typename LegacyCompletionHandler>
603  ASIO_INITFN_AUTO_RESULT_TYPE(LegacyCompletionHandler, void ())
604  post(ASIO_MOVE_ARG(LegacyCompletionHandler) handler);
605 
608 
628  template <typename Handler>
629 #if defined(GENERATING_DOCUMENTATION)
630  unspecified
631 #else
633 #endif
634  wrap(Handler handler);
635 #endif // !defined(ASIO_NO_DEPRECATED)
636 
637 private:
638  io_context(const io_context&) ASIO_DELETED;
639  io_context& operator=(const io_context&) ASIO_DELETED;
640 
641 #if !defined(ASIO_NO_DEPRECATED)
642  struct initiate_dispatch;
643  struct initiate_post;
644 #endif // !defined(ASIO_NO_DEPRECATED)
645 
646  // Helper function to add the implementation.
647  ASIO_DECL impl_type& add_impl(impl_type* impl);
648 
649  // Backwards compatible overload for use with services derived from
650  // io_context::service.
651  template <typename Service>
652  friend Service& use_service(io_context& ioc);
653 
654 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
655  detail::winsock_init<> init_;
656 #elif defined(__sun) || defined(__QNX__) || defined(__hpux) || defined(_AIX) \
657  || defined(__osf__)
658  detail::signal_init<> init_;
659 #endif
660 
661  // The implementation.
662  impl_type& impl_;
663 };
664 
665 namespace detail {
666 
667 } // namespace detail
668 
670 template <typename Allocator, unsigned int Bits>
672 {
673 public:
676  const basic_executor_type& other) ASIO_NOEXCEPT
677  : io_context_(other.io_context_),
678  allocator_(other.allocator_),
679  bits_(other.bits_)
680  {
681  if (Bits & outstanding_work_tracked)
682  if (io_context_)
683  io_context_->impl_.work_started();
684  }
685 
686 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
687  basic_executor_type(basic_executor_type&& other) ASIO_NOEXCEPT
689  : io_context_(other.io_context_),
690  allocator_(ASIO_MOVE_CAST(Allocator)(other.allocator_)),
691  bits_(other.bits_)
692  {
693  if (Bits & outstanding_work_tracked)
694  other.io_context_ = 0;
695  }
696 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
697 
699  ~basic_executor_type() ASIO_NOEXCEPT
700  {
701  if (Bits & outstanding_work_tracked)
702  if (io_context_)
703  io_context_->impl_.work_finished();
704  }
705 
707  basic_executor_type& operator=(
708  const basic_executor_type& other) ASIO_NOEXCEPT;
709 
710 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
711  basic_executor_type& operator=(
713  basic_executor_type&& other) ASIO_NOEXCEPT;
714 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
715 
717 
726  ASIO_CONSTEXPR basic_executor_type require(
728  {
729  return basic_executor_type(io_context_,
730  allocator_, bits_ & ~blocking_never);
731  }
732 
734 
743  ASIO_CONSTEXPR basic_executor_type require(
745  {
746  return basic_executor_type(io_context_,
747  allocator_, bits_ | blocking_never);
748  }
749 
751 
760  ASIO_CONSTEXPR basic_executor_type require(
762  {
763  return basic_executor_type(io_context_,
764  allocator_, bits_ & ~relationship_continuation);
765  }
766 
768 
777  ASIO_CONSTEXPR basic_executor_type require(
779  {
780  return basic_executor_type(io_context_,
781  allocator_, bits_ | relationship_continuation);
782  }
783 
785 
794  ASIO_CONSTEXPR basic_executor_type<Allocator,
795  ASIO_UNSPECIFIED(Bits | outstanding_work_tracked)>
797  {
799  io_context_, allocator_, bits_);
800  }
801 
803 
812  ASIO_CONSTEXPR basic_executor_type<Allocator,
813  ASIO_UNSPECIFIED(Bits & ~outstanding_work_tracked)>
815  {
817  io_context_, allocator_, bits_);
818  }
819 
821 
830  template <typename OtherAllocator>
833  {
835  io_context_, a.value(), bits_);
836  }
837 
839 
848  ASIO_CONSTEXPR basic_executor_type<std::allocator<void>, Bits>
850  {
851  return basic_executor_type<std::allocator<void>, Bits>(
852  io_context_, std::allocator<void>(), bits_);
853  }
854 
856 
866  static ASIO_CONSTEXPR execution::mapping_t query(
867  execution::mapping_t) ASIO_NOEXCEPT
868  {
869  return execution::mapping.thread;
870  }
871 
873 
882  io_context& query(execution::context_t) const ASIO_NOEXCEPT
883  {
884  return *io_context_;
885  }
886 
888 
898  ASIO_CONSTEXPR execution::blocking_t query(
899  execution::blocking_t) const ASIO_NOEXCEPT
900  {
901  return (bits_ & blocking_never)
902  ? execution::blocking_t(execution::blocking.never)
903  : execution::blocking_t(execution::blocking.possibly);
904  }
905 
907 
918  execution::relationship_t) const ASIO_NOEXCEPT
919  {
920  return (bits_ & relationship_continuation)
921  ? execution::relationship_t(execution::relationship.continuation)
922  : execution::relationship_t(execution::relationship.fork);
923  }
924 
926 
936  static ASIO_CONSTEXPR execution::outstanding_work_t query(
937  execution::outstanding_work_t) ASIO_NOEXCEPT
938  {
939  return (Bits & outstanding_work_tracked)
940  ? execution::outstanding_work_t(execution::outstanding_work.tracked)
941  : execution::outstanding_work_t(execution::outstanding_work.untracked);
942  }
943 
945 
954  template <typename OtherAllocator>
955  ASIO_CONSTEXPR Allocator query(
956  execution::allocator_t<OtherAllocator>) const ASIO_NOEXCEPT
957  {
958  return allocator_;
959  }
960 
962 
971  ASIO_CONSTEXPR Allocator query(
972  execution::allocator_t<void>) const ASIO_NOEXCEPT
973  {
974  return allocator_;
975  }
976 
978 
982  bool running_in_this_thread() const ASIO_NOEXCEPT;
983 
985 
988  friend bool operator==(const basic_executor_type& a,
989  const basic_executor_type& b) ASIO_NOEXCEPT
990  {
991  return a.io_context_ == b.io_context_
992  && a.allocator_ == b.allocator_
993  && a.bits_ == b.bits_;
994  }
995 
997 
1000  friend bool operator!=(const basic_executor_type& a,
1001  const basic_executor_type& b) ASIO_NOEXCEPT
1002  {
1003  return a.io_context_ != b.io_context_
1004  || a.allocator_ != b.allocator_
1005  || a.bits_ != b.bits_;
1006  }
1007 
1009 
1017  template <typename Function>
1018  void execute(ASIO_MOVE_ARG(Function) f) const;
1019 
1020 #if !defined(ASIO_NO_TS_EXECUTORS)
1021  io_context& context() const ASIO_NOEXCEPT;
1023 
1025 
1030  void on_work_started() const ASIO_NOEXCEPT;
1031 
1033 
1038  void on_work_finished() const ASIO_NOEXCEPT;
1039 
1041 
1054  template <typename Function, typename OtherAllocator>
1055  void dispatch(ASIO_MOVE_ARG(Function) f,
1056  const OtherAllocator& a) const;
1057 
1059 
1071  template <typename Function, typename OtherAllocator>
1072  void post(ASIO_MOVE_ARG(Function) f,
1073  const OtherAllocator& a) const;
1074 
1076 
1092  template <typename Function, typename OtherAllocator>
1093  void defer(ASIO_MOVE_ARG(Function) f,
1094  const OtherAllocator& a) const;
1095 #endif // !defined(ASIO_NO_TS_EXECUTORS)
1096 
1097 private:
1098  friend class io_context;
1099  template <typename, unsigned int> friend class basic_executor_type;
1100 
1101  // Constructor used by io_context::get_executor().
1102  explicit basic_executor_type(io_context& i) ASIO_NOEXCEPT
1103  : io_context_(&i),
1104  allocator_(),
1105  bits_(0)
1106  {
1107  if (Bits & outstanding_work_tracked)
1108  io_context_->impl_.work_started();
1109  }
1110 
1111  // Constructor used by require().
1113  const Allocator& a, unsigned int bits) ASIO_NOEXCEPT
1114  : io_context_(i),
1115  allocator_(a),
1116  bits_(bits)
1117  {
1118  if (Bits & outstanding_work_tracked)
1119  if (io_context_)
1120  io_context_->impl_.work_started();
1121  }
1122 
1123  // The underlying io_context.
1124  io_context* io_context_;
1125 
1126  // The allocator used for execution functions.
1127  Allocator allocator_;
1128 
1129  // The runtime-switched properties of the io_context executor.
1130  unsigned int bits_;
1131 };
1132 
1133 #if !defined(ASIO_NO_DEPRECATED)
1134 
1146 {
1147 public:
1149 
1154  explicit work(asio::io_context& io_context);
1155 
1157 
1162  work(const work& other);
1163 
1165 
1170  ~work();
1171 
1173  asio::io_context& get_io_context();
1174 
1175 private:
1176  // Prevent assignment.
1177  void operator=(const work& other);
1178 
1179  // The io_context implementation.
1180  detail::io_context_impl& io_context_impl_;
1181 };
1182 #endif // !defined(ASIO_NO_DEPRECATED)
1183 
1187 {
1188 public:
1190  asio::io_context& get_io_context();
1191 
1192 private:
1194  ASIO_DECL virtual void shutdown();
1195 
1196 #if !defined(ASIO_NO_DEPRECATED)
1197  ASIO_DECL virtual void shutdown_service();
1200 #endif // !defined(ASIO_NO_DEPRECATED)
1201 
1204 
1208  ASIO_DECL virtual void notify_fork(
1210 
1211 #if !defined(ASIO_NO_DEPRECATED)
1212 
1218  ASIO_DECL virtual void fork_service(
1220 #endif // !defined(ASIO_NO_DEPRECATED)
1221 
1222 protected:
1224 
1227  ASIO_DECL service(asio::io_context& owner);
1228 
1230  ASIO_DECL virtual ~service();
1231 };
1232 
1233 namespace detail {
1234 
1235 // Special service base class to keep classes header-file only.
1236 template <typename Type>
1238  : public asio::io_context::service
1239 {
1240 public:
1242 
1243  // Constructor.
1245  : asio::io_context::service(io_context)
1246  {
1247  }
1248 };
1249 
1250 template <typename Type>
1252 
1253 } // namespace detail
1254 
1255 #if !defined(GENERATING_DOCUMENTATION)
1256 
1257 namespace traits {
1258 
1259 #if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
1260 
1261 template <typename Allocator, unsigned int Bits>
1263  asio::io_context::basic_executor_type<Allocator, Bits>
1264  >
1265 {
1266  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1267  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
1268 };
1269 
1270 #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
1271 
1272 #if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
1273 
1274 template <typename Allocator, unsigned int Bits, typename Function>
1276  asio::io_context::basic_executor_type<Allocator, Bits>,
1277  Function
1278  >
1279 {
1280  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1281  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1282  typedef void result_type;
1283 };
1284 
1285 #endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
1286 
1287 #if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
1288 
1289 template <typename Allocator, unsigned int Bits>
1291  asio::io_context::basic_executor_type<Allocator, Bits>,
1293  >
1294 {
1295  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1296  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1298  Allocator, Bits> result_type;
1299 };
1300 
1301 template <typename Allocator, unsigned int Bits>
1303  asio::io_context::basic_executor_type<Allocator, Bits>,
1305  >
1306 {
1307  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1308  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1310  Allocator, Bits> result_type;
1311 };
1312 
1313 template <typename Allocator, unsigned int Bits>
1315  asio::io_context::basic_executor_type<Allocator, Bits>,
1317  >
1318 {
1319  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1320  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1322  Allocator, Bits> result_type;
1323 };
1324 
1325 template <typename Allocator, unsigned int Bits>
1327  asio::io_context::basic_executor_type<Allocator, Bits>,
1329  >
1330 {
1331  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1332  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1334  Allocator, Bits> result_type;
1335 };
1336 
1337 template <typename Allocator, unsigned int Bits>
1339  asio::io_context::basic_executor_type<Allocator, Bits>,
1342 {
1343  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1344  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1346  Allocator, Bits | outstanding_work_tracked> result_type;
1347 };
1348 
1349 template <typename Allocator, unsigned int Bits>
1351  asio::io_context::basic_executor_type<Allocator, Bits>,
1354 {
1355  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1356  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1358  Allocator, Bits & ~outstanding_work_tracked> result_type;
1359 };
1360 
1361 template <typename Allocator, unsigned int Bits>
1363  asio::io_context::basic_executor_type<Allocator, Bits>,
1365  >
1366 {
1367  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1368  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1370  std::allocator<void>, Bits> result_type;
1371 };
1372 
1373 template <unsigned int Bits,
1374  typename Allocator, typename OtherAllocator>
1376  asio::io_context::basic_executor_type<Allocator, Bits>,
1377  asio::execution::allocator_t<OtherAllocator>
1378  >
1379 {
1380  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1381  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
1383  OtherAllocator, Bits> result_type;
1384 };
1385 
1386 #endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
1387 
1388 #if !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
1389 
1390 template <typename Allocator, unsigned int Bits, typename Property>
1392  asio::io_context::basic_executor_type<Allocator, Bits>,
1393  Property,
1394  typename asio::enable_if<
1395  asio::is_convertible<
1396  Property,
1397  asio::execution::outstanding_work_t
1398  >::value
1399  >::type
1401 {
1402  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1403  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
1405 
1406  static ASIO_CONSTEXPR result_type value() ASIO_NOEXCEPT
1407  {
1408  return (Bits & outstanding_work_tracked)
1409  ? execution::outstanding_work_t(execution::outstanding_work.tracked)
1410  : execution::outstanding_work_t(execution::outstanding_work.untracked);
1411  }
1412 };
1413 
1414 template <typename Allocator, unsigned int Bits, typename Property>
1416  asio::io_context::basic_executor_type<Allocator, Bits>,
1417  Property,
1418  typename asio::enable_if<
1419  asio::is_convertible<
1420  Property,
1421  asio::execution::mapping_t
1422  >::value
1423  >::type
1424  >
1425 {
1426  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1427  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
1429 
1430  static ASIO_CONSTEXPR result_type value() ASIO_NOEXCEPT
1431  {
1432  return result_type();
1433  }
1434 };
1435 
1436 #endif // !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
1437 
1438 #if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
1439 
1440 template <typename Allocator, unsigned int Bits, typename Property>
1442  asio::io_context::basic_executor_type<Allocator, Bits>,
1443  Property,
1444  typename asio::enable_if<
1445  asio::is_convertible<
1446  Property,
1447  asio::execution::blocking_t
1448  >::value
1449  >::type
1450  >
1451 {
1452  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1453  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
1455 };
1456 
1457 template <typename Allocator, unsigned int Bits, typename Property>
1459  asio::io_context::basic_executor_type<Allocator, Bits>,
1460  Property,
1461  typename asio::enable_if<
1462  asio::is_convertible<
1463  Property,
1464  asio::execution::relationship_t
1465  >::value
1466  >::type
1467  >
1468 {
1469  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1470  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
1472 };
1473 
1474 template <typename Allocator, unsigned int Bits>
1476  asio::io_context::basic_executor_type<Allocator, Bits>,
1478  >
1479 {
1480  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1481  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
1482  typedef asio::io_context& result_type;
1483 };
1484 
1485 template <typename Allocator, unsigned int Bits>
1487  asio::io_context::basic_executor_type<Allocator, Bits>,
1489  >
1490 {
1491  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1492  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
1493  typedef Allocator result_type;
1494 };
1495 
1496 template <typename Allocator, unsigned int Bits, typename OtherAllocator>
1498  asio::io_context::basic_executor_type<Allocator, Bits>,
1499  asio::execution::allocator_t<OtherAllocator>
1500  >
1501 {
1502  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
1503  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
1504  typedef Allocator result_type;
1505 };
1506 
1507 #endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
1508 
1509 } // namespace traits
1510 
1511 #endif // !defined(GENERATING_DOCUMENTATION)
1512 
1513 } // namespace asio
1514 
1515 #include "asio/detail/pop_options.hpp"
1516 
1517 #include "asio/impl/io_context.hpp"
1518 #if defined(ASIO_HEADER_ONLY)
1519 # include "asio/impl/io_context.ipp"
1520 #endif // defined(ASIO_HEADER_ONLY)
1521 
1522 // If both io_context.hpp and strand.hpp have been included, automatically
1523 // include the header file needed for the io_context::strand class.
1524 #if !defined(ASIO_NO_EXTENSIONS)
1525 # if defined(ASIO_STRAND_HPP)
1526 # include "asio/io_context_strand.hpp"
1527 # endif // defined(ASIO_STRAND_HPP)
1528 #endif // !defined(ASIO_NO_EXTENSIONS)
1529 
1530 #endif // ASIO_IO_CONTEXT_HPP
static ASIO_CONSTEXPR execution::mapping_t query(execution::mapping_t) ASIO_NOEXCEPT
Query the current value of the mapping property.
Definition: io_context.hpp:866
Definition: relationship.hpp:157
ASIO_CONSTEXPR basic_executor_type< Allocator, ASIO_UNSPECIFIED(Bits|outstanding_work_tracked)> require(execution::outstanding_work_t::tracked_t) const
Obtain an executor with the outstanding_work.tracked property.
Definition: io_context.hpp:796
ASIO_CONSTEXPR execution::relationship_t query(execution::relationship_t) const ASIO_NOEXCEPT
Query the current value of the relationship property.
Definition: io_context.hpp:917
friend bool operator==(const basic_executor_type &a, const basic_executor_type &b) ASIO_NOEXCEPT
Compare two executors for equality.
Definition: io_context.hpp:988
Definition: blocking.hpp:208
static ASIO_CONSTEXPR execution::outstanding_work_t query(execution::outstanding_work_t) ASIO_NOEXCEPT
Query the current value of the outstanding_work property.
Definition: io_context.hpp:936
std::size_t count_type
The type used to count the number of handlers executed by the context.
Definition: io_context.hpp:239
Definition: signal_init.hpp:30
ASIO_CONSTEXPR basic_executor_type require(execution::relationship_t::fork_t) const
Obtain an executor with the relationship.fork property.
Definition: io_context.hpp:760
Base class for all io_context services.
Definition: io_context.hpp:1185
Definition: blocking.hpp:193
ASIO_CONSTEXPR basic_executor_type< OtherAllocator, Bits > require(execution::allocator_t< OtherAllocator > a) const
Obtain an executor with the specified allocator property.
Definition: io_context.hpp:832
Definition: io_context.hpp:1237
ASIO_CONSTEXPR basic_executor_type< std::allocator< void >, Bits > require(execution::allocator_t< void >) const
Obtain an executor with the default allocator property.
Definition: io_context.hpp:849
Definition: query_member.hpp:38
ASIO_CONSTEXPR basic_executor_type require(execution::blocking_t::never_t) const
Obtain an executor with the blocking.never property.
Definition: io_context.hpp:743
Provides serialised handler execution.
Definition: io_context_strand.hpp:89
~basic_executor_type() ASIO_NOEXCEPT
Destructor.
Definition: io_context.hpp:699
basic_executor_type(const basic_executor_type &other) ASIO_NOEXCEPT
Copy constructor.
Definition: io_context.hpp:675
Base class for all io_context services.
Definition: execution_context.hpp:315
basic_executor_type< std::allocator< void >, 0 > executor_type
Executor used to submit functions to an io_context.
Definition: io_context.hpp:228
A context for function object execution.
Definition: execution_context.hpp:105
ASIO_INITFN_AUTO_RESULT_TYPE(RangeConnectHandler, void(asio::error_code, typename Protocol::endpoint)) async_connect(basic_socket< Protocol
Asynchronously establishes a socket connection by trying each endpoint in a sequence.
ASIO_CONSTEXPR basic_executor_type require(execution::relationship_t::continuation_t) const
Obtain an executor with the relationship.continuation property.
Definition: io_context.hpp:777
Definition: execute_member.hpp:38
Provides core I/O functionality.
Definition: io_context.hpp:211
Definition: chrono.h:284
Definition: allocator.hpp:78
Definition: type_traits.hpp:97
fork_event
Fork-related event notifications.
Definition: execution_context.hpp:142
Definition: mapping.hpp:192
Definition: require_member.hpp:38
Executor implementation type used to submit functions to an io_context.
Definition: io_context.hpp:222
(Deprecated: Use executor_work_guard.) Class to inform the io_context when it has work to do...
Definition: io_context.hpp:1145
Definition: outstanding_work.hpp:158
friend bool operator!=(const basic_executor_type &a, const basic_executor_type &b) ASIO_NOEXCEPT
Compare two executors for inequality.
Definition: io_context.hpp:1000
Definition: outstanding_work.hpp:153
ASIO_CONSTEXPR Allocator query(execution::allocator_t< OtherAllocator >) const ASIO_NOEXCEPT
Query the current value of the allocator property.
Definition: io_context.hpp:955
Definition: io_context.hpp:57
Class to represent an error code value.
Definition: error_code.hpp:80
Definition: query_static_constexpr_member.hpp:42
Definition: io_context.hpp:121
ASIO_CONSTEXPR basic_executor_type require(execution::blocking_t::possibly_t) const
Obtain an executor with the blocking.possibly property.
Definition: io_context.hpp:726
ASIO_CONSTEXPR basic_executor_type< Allocator, ASIO_UNSPECIFIED(Bits &~outstanding_work_tracked)> require(execution::outstanding_work_t::untracked_t) const
Obtain an executor with the outstanding_work.untracked property.
Definition: io_context.hpp:814
Definition: wrapped_handler.hpp:48
Definition: relationship.hpp:151
Definition: io_context.hpp:165
Definition: context.hpp:69
ASIO_CONSTEXPR Allocator query(execution::allocator_t< void >) const ASIO_NOEXCEPT
Query the current value of the allocator property.
Definition: io_context.hpp:971
Definition: allocator.hpp:132
io_context & query(execution::context_t) const ASIO_NOEXCEPT
Query the current value of the context property.
Definition: io_context.hpp:882
Definition: any_io_executor.hpp:28
ASIO_CONSTEXPR execution::blocking_t query(execution::blocking_t) const ASIO_NOEXCEPT
Query the current value of the blocking property.
Definition: io_context.hpp:898
Definition: scheduler.hpp:38
Definition: outstanding_work.hpp:152
Definition: execution_context.hpp:379
Definition: equality_comparable.hpp:36