Boost logo

Boost :

Subject: Re: [boost] [fiber] Suggestions regarding asio
From: Tatsuyuki Ishi (ishitatsuyuki_at_[hidden])
Date: 2016-09-23 02:46:04


It would be better if you used "Reply to All", since I disabled the
delivery from the list.

> When considering using multiple threads with an io_service passed to a
custom Boost.Fiber scheduler, I keep bumping into the problem that a given
fiber scheduler instance must always run on its original thread -- but I
know of no way to give an Asio handler "thread affinity." How do we get
processor cycles to the scheduler on the thread whose fibers it is managing?
Since we only poll on one master thread, we can easily get affinity.

Maybe pseudocode is easier:
* We have two class, one for main polling, others waiting for job.
* The first one, polls from asio using the same way as the example (poll,
or run_one).
while(true)
{
if(!run_one()) stop_other_threads(); // No more work in asio, give up
waiting
poll(); // flush the queue
// Now we should have some fibers in the queue.
yield(); // continue execution
}
* Other threads, uses condvar to wait on the ready queue.
awakened(){queue.push_back(f); cv.notify_[one,all](); iosvc.post([]{});}
pick_next(){while(!jobs_available){cv.wait();} return job;}


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