Boost logo

Boost Users :

Subject: Re: [Boost-users] Thread_group semantics
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-01-13 18:22:46


On 14/01/2014 11:49, Quoth Kenneth Adam Miller:
> Yeah it stores threads, not tasks, but isn't it true that you dispatch
> jobs to the current thread group using ioService.post? Maybe my question
> was wrong, because I went off using this recipe
> http://stackoverflow.com/questions/19500404/how-to-create-a-thread-pool-using-boost-in-c

That's a bad recipe. Don't write code like that. (work and the threads
are constructed in the wrong order, and stopping immediately after
posting will not necessarily execute anything.)

Read the Boost.Asio docs
(http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio.html) and
examples instead.

But, to answer your immediate question: Boost.Asio's io_service acts
like a queue. It can store an unlimited (except by memory) number of
tasks and they are executed in a loosely FIFO order ("loosely" as tasks
may execute concurrently and thus apparently out of order when multiple
worker threads are used).


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