Boost logo

Boost :

Subject: [boost] Boost Fiber & ASIO CPU spinning
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2016-12-26 15:57:26


I am attempting to combine Boost Fiber with Boost ASIO and am having very
poor results.

Code:

int main() {
   boost::asio::io_service io;
   boost::fibers::use_scheduling_algorithm<
boost::fibers::asio::round_robin > ( io );
   io.run();
   return 0;
}

This code should startup and then sleep, but instead it pegs the CPU at
100%.

The code I used for boost::fibers::asio::round_robin can be found here:
http://www.boost.org/doc/libs/1_62_0/libs/fiber/examples/asio/round_robin.hpp

When I inspect the round_robin scheduler it appears to be switching back
and forth between two different fibers. If I put a print statement
inside asio_rr_service_lambda
then it constantly reports that it has ready fibers.

I'm looking for a working example.

Dan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk