Код: Выделить всё
template
decltype(auto) test_initiate(CompletionToken&& token) {
return boost::asio::async_initiate([](auto&& handler) mutable { std::move(handler)(); },
token);
}
struct compose_tester {
template
void operator()(Self& self) {
self.complete();
}
};
template
decltype(auto) test_compose(CompletionToken&& token) {
return boost::asio::async_compose(compose_tester{}, token);
}
Но что, если я вызову методы примера с помощьюbind_executor?
Код: Выделить всё
boost::asio::io_context ioc1;
boost::asio::io_context ioc2;
std::thread::id t0_id = std::this_thread::get_id();
std::thread::id t1_id;
std::thread::id t2_id;
// Hide the code that runs ioc1 & ioc2 in two threads and sets t1_id & t2_id. Proper work_guard objects have been created.
test_initiate(boost::asio::bind_executor(ioc2, [&]() {
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/79692266/why-doesnt-boostasioasync-initiate-or-async-compose-automatically-call-the[/url]
Мобильная версия