Boost logo

Boost :

Subject: Re: [boost] Interested in bounded buffer class for threaded producer/consumer communication?
From: André Offringa (offringa_at_[hidden])
Date: 2011-12-13 07:23:26

On 12/13/2011 02:43 AM, Robert Ramey wrote:
> André Offringa wrote:
>> Hi all,
>> I seem to have come across a producer/consumer situation a few times
>> now, and everytime I do, I seem to want a slightly different
>> functionality for a bounded buffer-kind of class that is not generally
>> provided. I am looking for such a class that is also efficient for
>> large amounts of data, and so I wonder if there does already exists a
>> class in boost to efficiently push work between producers and
>> consumers when they are running in different threads, i.e., that is thread
>> safe. [..]
> I used an example from circular_buffer library. Worked great
> and only a few minutes to insert into my app.

Hi Robert,

Thanks for your reply. Just to clarify, that example was actually the
one I was referring to my mail:

"There is a bounded_buffer example given to implement such a thing with
the circular buffer. It does exactly what I suggest, but I assume it is
not so efficient for pushing large amounts of data over, as each
individual object requires a push, thus a lock implemented as in
bounded_buffer, and involves unnecessary updates of the counters
(involving a decrement() each time) on each push, which is not necessary
if you know you are pushing a number of elements at once. I assume this
could be fixed by wrapping the insert(range) method instead of the
individual push functions."

Apart from not providing an efficient push of a range, it misses the
write_end() functionality that I mentioned. Hence the question if that
would be something which is generally useful, or if it is just in my case.

Eitherway, I agree that the bounded_buffer example is on itself already
useful in many situations.


Boost list run by bdawes at, gregod at, cpdaniel at, john at