File indexing completed on 2025-01-30 10:01:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_THREAD_EXECUTORS_EXECUTOR_ADAPTOR_HPP
0010 #define BOOST_THREAD_EXECUTORS_EXECUTOR_ADAPTOR_HPP
0011
0012 #include <boost/thread/detail/config.hpp>
0013 #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION && defined BOOST_THREAD_PROVIDES_EXECUTORS && defined BOOST_THREAD_USES_MOVE
0014
0015 #include <boost/thread/executors/executor.hpp>
0016
0017 #include <boost/config/abi_prefix.hpp>
0018
0019 namespace boost
0020 {
0021 namespace executors
0022 {
0023
0024
0025
0026 template <typename Executor>
0027 class executor_adaptor : public executor
0028 {
0029 Executor ex;
0030 public:
0031
0032 typedef executor::work work;
0033
0034
0035 BOOST_THREAD_NO_COPYABLE(executor_adaptor)
0036
0037
0038
0039
0040 #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0041 template <typename ...Args>
0042 executor_adaptor(BOOST_THREAD_RV_REF(Args) ... args) : ex(boost::forward<Args>(args)...) {}
0043 #else
0044
0045
0046
0047 executor_adaptor() : ex() {}
0048
0049 template <typename A1>
0050 executor_adaptor(
0051 BOOST_THREAD_FWD_REF(A1) a1
0052 ) :
0053 ex(
0054 boost::forward<A1>(a1)
0055 ) {}
0056 template <typename A1, typename A2>
0057 executor_adaptor(
0058 BOOST_THREAD_FWD_REF(A1) a1,
0059 BOOST_THREAD_FWD_REF(A2) a2
0060 ) :
0061 ex(
0062 boost::forward<A1>(a1),
0063 boost::forward<A2>(a2)
0064 ) {}
0065 template <typename A1, typename A2, typename A3>
0066 executor_adaptor(
0067 BOOST_THREAD_FWD_REF(A1) a1,
0068 BOOST_THREAD_FWD_REF(A2) a2,
0069 BOOST_THREAD_FWD_REF(A3) a3
0070 ) :
0071 ex(
0072 boost::forward<A1>(a1),
0073 boost::forward<A2>(a2),
0074 boost::forward<A3>(a3)
0075 ) {}
0076 #endif
0077 Executor& underlying_executor() { return ex; }
0078
0079
0080
0081
0082
0083 void close() { ex.close(); }
0084
0085
0086
0087
0088 bool closed() { return ex.closed(); }
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 void submit(BOOST_THREAD_RV_REF(work) closure) {
0100 return ex.submit(boost::move(closure));
0101 }
0102
0103 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0104 template <typename Closure>
0105 void submit(Closure & closure)
0106 {
0107 submit(work(closure));
0108 }
0109 #endif
0110 void submit(void (*closure)())
0111 {
0112 submit(work(closure));
0113 }
0114
0115 template <typename Closure>
0116 void submit(BOOST_THREAD_FWD_REF(Closure) closure)
0117 {
0118
0119 work w((boost::forward<Closure>(closure)));
0120 submit(boost::move(w));
0121 }
0122
0123
0124
0125
0126
0127
0128 bool try_executing_one() { return ex.try_executing_one(); }
0129
0130 };
0131 }
0132 using executors::executor_adaptor;
0133 }
0134
0135 #include <boost/config/abi_suffix.hpp>
0136
0137 #endif
0138 #endif