Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] schedule work on all threads of a single io_service::run() pool?
From: Anthony Foiani (tkil_at_[hidden])
Date: 2013-05-18 16:26:27


Igor --

Thanks for the quick reply.

Igor R <boost.lists_at_[hidden]> writes:

>> Is there a way to ask the io_service to distribute a particular
>> handler to every thread that is running the service?
>> My use case is per-thread watchdogs, and I need the worker threads to
>> ping the watchdog on some regular interval (e.g., every 5 seconds).

> No, io_service threads are expected to be used for scalability
> purposes only, and the application logic is expected to be
> "decoupled" from the threading.

Ok, that makes sense. I think I confused myself: thinking that the
per-thread "heartbeat" isn't really application logic, so much as
low-level plumbing...

> What you can do instead is to use multiple io_service's, instead of
> multiple threads running 1 io_service (see io_service-per-CPU
> example).

Hm. Let stare at that example for a bit. [Ponders] I think I
understand what you're getting at.

I want to set up an io_service-per-thread, with each io_service having
a deadline_timer to handle the heartbeat. The only other complicated
bit is selecting an io_service to handle an incoming request.

It's a bit irksome to have to trade off the scalability to get this
extra feature. I wonder if I can somehow do a double dispatch of
sorts, or maybe do some accounting to see if I can make sure I always
select an idle io_service if possible.

Thanks again for the reply.

Best regards,
Anthony Foiani


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net