Boost logo

Boost :

From: Tony Juricic (tonygeek_at_[hidden])
Date: 2004-09-05 11:03:35

"John Torjo" wrote:

> > I would argue that most of multi-threaded programs need thread-safe
> > containers.
> I tend not to agree with you (see above).

I am not sure I understand it well, so let's try with a concrete example of
FIFO queue.
Let's say you are asynchronously receiving message blocks (not necessarily
of fixed size) and you implement that with two threads:
- one is accumulating data until message end is found and puts the block in
the queue
- another reads and parses message blocks

At this point the chunkiness of the data and the fact that data for message
blocks arrive asynchronously is modelled via element membership in the queue
container which must be accessed in a thread-safe manner.

Thread-safe queue (whether lock-free or using 'ordinary' locks on all
accessors) seems a way to implement this without programmer
having to explicitly consider threading issues. One programmer puts the data
block, another picks them and parses them.

How woud you model this in your, right way? What is the guiding idea?


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