| 1118 | |
| 1119 | template <typename Executor> |
| 1120 | class initiate_spawn |
| 1121 | { |
| 1122 | public: |
| 1123 | typedef Executor executor_type; |
| 1124 | |
| 1125 | explicit initiate_spawn(const executor_type& ex) |
| 1126 | : executor_(ex) |
| 1127 | { |
| 1128 | } |
| 1129 | |
| 1130 | executor_type get_executor() const ASIO_NOEXCEPT |
| 1131 | { |
| 1132 | return executor_; |
| 1133 | } |
| 1134 | |
| 1135 | template <typename Handler, typename F> |
| 1136 | void operator()(ASIO_MOVE_ARG(Handler) handler, |
| 1137 | ASIO_MOVE_ARG(F) f) const |
| 1138 | { |
| 1139 | typedef typename decay<Handler>::type handler_type; |
| 1140 | typedef typename decay<F>::type function_type; |
| 1141 | typedef spawn_cancellation_handler< |
| 1142 | handler_type, Executor> cancel_handler_type; |
| 1143 | |
| 1144 | typename associated_cancellation_slot<handler_type>::type slot |
| 1145 | = asio::get_associated_cancellation_slot(handler); |
| 1146 | |
| 1147 | cancel_handler_type* cancel_handler = slot.is_connected() |
| 1148 | ? &slot.template emplace<cancel_handler_type>(handler, executor_) |
| 1149 | : 0; |
| 1150 | |
| 1151 | cancellation_slot proxy_slot( |
| 1152 | cancel_handler |
| 1153 | ? cancel_handler->slot() |
| 1154 | : cancellation_slot()); |
| 1155 | |
| 1156 | cancellation_state cancel_state(proxy_slot); |
| 1157 | |
| 1158 | (dispatch)(executor_, |
| 1159 | spawned_thread_resumer( |
| 1160 | default_spawned_thread_type::spawn( |
| 1161 | spawn_entry_point<Executor, function_type, handler_type>( |
| 1162 | executor_, ASIO_MOVE_CAST(F)(f), |
| 1163 | ASIO_MOVE_CAST(Handler)(handler)), |
| 1164 | proxy_slot, cancel_state))); |
| 1165 | } |
| 1166 | |
| 1167 | #if defined(ASIO_HAS_BOOST_CONTEXT_FIBER) |
| 1168 | |
| 1169 | template <typename Handler, typename StackAllocator, typename F> |
| 1170 | void operator()(ASIO_MOVE_ARG(Handler) handler, allocator_arg_t, |
| 1171 | ASIO_MOVE_ARG(StackAllocator) stack_allocator, |
| 1172 | ASIO_MOVE_ARG(F) f) const |
| 1173 | { |
| 1174 | typedef typename decay<Handler>::type handler_type; |
| 1175 | typedef typename decay<F>::type function_type; |
| 1176 | typedef spawn_cancellation_handler< |
| 1177 | handler_type, Executor> cancel_handler_type; |
nothing calls this directly
no test coverage detected