Re: (No) Thread safty in VC 7.1 STL?
From: Arnaud Debaene (adebaene_at_club-internet.fr)
Date: 07/16/04
- Next message: Igor Tandetnik: "Re: Tricky one.. window text spy problem"
- Previous message: Erik Nordahl: "(No) Thread safty in VC 7.1 STL?"
- In reply to: Erik Nordahl: "(No) Thread safty in VC 7.1 STL?"
- Next in thread: P.J. Plauger: "Re: (No) Thread safty in VC 7.1 STL?"
- Reply: P.J. Plauger: "Re: (No) Thread safty in VC 7.1 STL?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Jul 2004 14:55:42 +0200
Erik Nordahl wrote:
> Browsing in MSDN (for VS .NET 2003), I found the following:
>
> Quote START:
>
> When /MT, /MTd, /MD, or /MDd is used, the following thread-safety
> rules are in effect:
>
> Container Classes (vector, deque, list, queue, stack , priority_queue,
> valarray, map, multimap, set, multiset, basic_string, bitset) and
> complex
> For reads to the same object, the object is thread safe for reading:
>
> From one thread at a time when no writers on other threads.
> From many threads at a time when no writers on other threads.
> For writes to the same object, the object is thread safe for writing
> from one thread when no readers on other threads
>
> NOTE FOLLOWING LINE -->
> For reads to different objects of the same class, the object is thread
> safe for reading:
>
> From one thread at a time.
> From one thread at a time when no writers on other threads.
> From many threads at a time.
> From many threads at a time when no writers on other threads.
> For writes to different objects of the same class, the object is
> thread safe for writing:
>
> From one thread when no readers on other threads.
> From many threads.
>
> Quote END:
>
> My question: Can it be true that a write operation on ANY object of a
> certain type (e.g. vector) will endanger any read operation on ANY
> object of the same type (in any thread)?
No, if the 2 objects are different, you can write to them separately without
problem. There was a problem in VC6 because the STL implementation of some
containers used static varaibles, but this is no longer true in VC7 and
VC7.1.
>
> Because that will in effect make the STL implementation useless in
> multithread applications...
I agree that the MSDN documentation is not very explicit...
Arnaud
MVP - VC
- Next message: Igor Tandetnik: "Re: Tricky one.. window text spy problem"
- Previous message: Erik Nordahl: "(No) Thread safty in VC 7.1 STL?"
- In reply to: Erik Nordahl: "(No) Thread safty in VC 7.1 STL?"
- Next in thread: P.J. Plauger: "Re: (No) Thread safty in VC 7.1 STL?"
- Reply: P.J. Plauger: "Re: (No) Thread safty in VC 7.1 STL?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|