[boost asio interaction] Restarting an io_service
- Lenguaje dominante
- C++
- Estrellas
- 510
- Forks
- 123
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Hi,
I am using the Boost.Fiber <-> Boost.Asio coupling via the `boost::fibers::asio::round_robin` scheduler, and I am trying to relaunch an asio `io_service`, that has previously been stopped.
The problem is, that the scheduler (or fiber) hangs after the second execution of the `.run()` method.
In the code example below, the "this line is never reached\n" string is never printed.
```cpp
#include
#include
#include "round_robin.hpp"
#include
using io_context_ptr = std::shared_ptr;
void start(io_context_ptr io_ctx)
{
boost::asio::system_timer t(*io_ctx);
t.expires_after(std::chrono::seconds(1));
t.async_wait(boost::fibers::asio::yield);
io_ctx->stop();
}
int main()
{
io_context_ptr io_ctx = std::make_shared();
boost::fibers::use_scheduling_algorithm(io_ctx);
auto f = boost::fibers::fiber(start, io_ctx);
io_ctx->run();
f.join();
std::cout << "foo\n";
io_ctx->restart();
auto f2 = boost::fibers::fiber(start, io_ctx);
std::cout << "bar\n";
io_ctx->run();
std::cout << "this line is never reached\n";
f2.join();
}
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.