protecting access to std::map

S

Shea Martin

I have multiple threads that need access to single std::map. Currently
I am using mutex's to regulate ANY access to the list.

My questionion is, is it safe to have multiple threads READING the list
at the same time, so long as they don't alter it?

~S
 
J

joe

Shea Martin said:
I have multiple threads that need access to single std::map.
Currently I am using mutex's to regulate ANY access to the list.

My questionion is, is it safe to have multiple threads READING the
list at the same time, so long as they don't alter it?

Theoretically, unless there's a thread writing to it as well.

Try posting this question to comp.programming.threads

Joe
 
F

Fletcher Glenn

Theoretically, unless there's a thread writing to it as well.

Try posting this question to comp.programming.threads

Joe

I would have to agree with this answer. Many std::map's are
implemented as an AVL tree under the covers. It would not
do to well to be doing a read-only walk down a tree when the
pointers begin shifting around.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top