boostorg / boostorg/fiber

[boost asio interaction] Restarting an io_service

Offen
#239 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
510
Forks
123
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.