boostorg / boostorg/fiber

[boost asio interaction] Restarting an io_service

未关闭
#239 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
510
派生
123
PR 合并指标
30 天内没有已合并 PR

描述

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();

}
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。