Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-10-05 14:18:32


Gottlob Frege wrote:
> 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
>>
>>
> 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?

It's very likely that #1+#2 will become the default level of thread safety
for everything in C++. Of course one would be able to override this default
by explicitly specifying in the documentation that a 'const' member function
isn't really 'const' from thread safety point of view. But most, if not all,
of the standard library will be #1+#2 (just like it offers basic exception
safety by default, without it being explicitly documented on a function by
function basis).


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