Re: Share a read-only std::list between two threads
- From: "Dmitriy V'jukov" <dvyukov@xxxxxxxxx>
- Date: Tue, 4 Mar 2008 01:25:34 -0800 (PST)
On 4 мар, 01:46, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
On Mar 3, 11:41 am, Marcin 'Qrczak' Kowalczyk <qrc...@xxxxxxxxxx>
wrote:
In theory yes, but a hash table which cares about threads emulates
safety guarantees of simple C types: concurrent reads should be safe.
So the questions is, do you have a hash table which cares about
threads?
I suspect that any serious C++ implementation which can be used with
multiple threads at all makes such guarantee, even if implicitly.
I would hope so. Threads and C++ are mature enough now that I think we
should be able to expect standard library types to work like normal
types. Hopefully, the number of exceptions to this rule will be small
and make sense.
I'm not so sure how far we've come on this front.
It's implementation-defined in C++.
MSDN explicitly states:
"The container classes are vector, deque, list, queue, stack,
priority_queue, valarray, map, hash_map, multimap, hash_multimap, set,
hash_set, multiset, hash_multiset, basic_string, and bitset.
A single object is thread safe for reading from multiple threads. For
example, given an object A, it is safe to read A from thread 1 and
from thread 2 simultaneously.
...
It is safe to read and write to one instance of a type even if another
thread is reading or writing to a different instance of the same type.
For example, given objects A and B of the same type, it is safe if A
is being written in thread 1 and B is being read in thread 2."
Dmitriy V'jukov
.
- Follow-Ups:
- Re: Share a read-only std::list between two threads
- From: Chris Thomasson
- Re: Share a read-only std::list between two threads
- References:
- Share a read-only std::list between two threads
- From: h.wulff
- Re: Share a read-only std::list between two threads
- From: Chris Thomasson
- Re: Share a read-only std::list between two threads
- From: SJBartnikowski@xxxxxxxxx
- Re: Share a read-only std::list between two threads
- From: Greg Herlihy
- Re: Share a read-only std::list between two threads
- From: David Schwartz
- Re: Share a read-only std::list between two threads
- From: Marcin ‘Qrczak’ Kowalczyk
- Re: Share a read-only std::list between two threads
- From: David Schwartz
- Share a read-only std::list between two threads
- Prev by Date: Stack Size in NPTL
- Next by Date: Re: Stack Size in NPTL
- Previous by thread: Re: Share a read-only std::list between two threads
- Next by thread: Re: Share a read-only std::list between two threads
- Index(es):
Relevant Pages
|