Boost logo

Boost Users :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2006-10-05 13:24:32


On 10/5/06, Joaquín Mª López Muñoz <joaquin_at_[hidden]> wrote:
>
> No, it is not safe to insert from two threads into the same container. The
> thread safety guarantees aplying to Boost.MultiIndex (and to most STL
> implementations as well) are:
>
> 1. Concurrent access to different containers is safe.
> 2. Concurrent read-only access to the same container is safe
>
> Joaquín M López Muñoz
> Telefónica, Investigación y Desarrollo
>
>
I know the standard says nothing about thread-safety (and I also know they
are thinking about saying a few things next time), but I was just wondering
what everyone thinks about #2 above - concurrent reads to the same
container. I've assumed that in the past as well, but how safe do people
think that is? If they add threading to the next standard, will they likely
add #2 as a requirement on the standard containers? What I'm thinking
about, for example, is a map-like container based on, say, splay trees,
where the last accessed item gets moved towards the top of the tree, which
is a nice property for caches. But this would mean mutable data that changes
during reads. So I would have to protect that with a mutex or something?

Thanks,
Tony



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