Is STL map::find thread safe? 
Author Message
 Is STL map::find thread safe?

Hi all
Is STL map::find function thread safe?
e.g I have a map<string, int> ( STL string). Different threads call
'map::find' function simultaneously, to retrieve the value for a given
string. Is there any chance that a thread gets the value, corresponding to a
string sumbmitted by another thread?

regards
neo



Sun, 26 Dec 2004 18:38:36 GMT  
 Is STL map::find thread safe?

Quote:

> Is STL map::find function thread safe?
> e.g I have a map<string, int> ( STL string). Different threads call
> 'map::find' function simultaneously, to retrieve the value for a given
> string. Is there any chance that a thread gets the value, corresponding to a
> string sumbmitted by another thread?

Multiple readers can access the same map object without mutual interference.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com



Sun, 26 Dec 2004 19:38:07 GMT  
 Is STL map::find thread safe?
Hi
More details about the situation
The contents of the map is static and there are no threads which will
insert/remove map contents dynamically.
But diff. threads are calling 'map::find' function for data retrieval.
Whether any protection is required here ( i.e read lock)?

thanks ..

neo


Quote:

> > Is STL map::find function thread safe?
> > e.g I have a map<string, int> ( STL string). Different threads call
> > 'map::find' function simultaneously, to retrieve the value for a given
> > string. Is there any chance that a thread gets the value, corresponding
to a
> > string sumbmitted by another thread?

> Multiple readers can access the same map object without mutual
interference.

> P.J. Plauger
> Dinkumware, Ltd.
> http://www.dinkumware.com



Mon, 27 Dec 2004 13:22:09 GMT  
 Is STL map::find thread safe?

Quote:

> Hi
> More details about the situation
> The contents of the map is static and there are no threads which will
> insert/remove map contents dynamically.
> But diff. threads are calling 'map::find' function for data retrieval.
> Whether any protection is required here ( i.e read lock)?

Read the previous answer:

:: Multiple readers can access the same map object without mutual
interference.

You don't need a read lock. Multiple readers will co-exist quite happily.

Loz.



Mon, 27 Dec 2004 17:17:27 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. map.find thread safe ?

2. Thread safe Map

3. Thread safe Map

4. Thread safe hash or map class?

5. Thread Safe Map

6. thread safe map

7. Thread-safe STL containers

8. Does VC++ 6.0 have a thread-safe STL?

9. Making thread safe STL containers

10. STL thread-safe ?

11. Does VC STL thread-safe?

12. Is STL/STDC++ library thread safe?

 

 
Powered by phpBB® Forum Software