By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

Urgent Help Needed.. About Stl Map

P: 9
Hi all,

ok here it goes..

I am going to implement a STL MAP.. say 'mapToken'..this is a GLOBAL map.

This mapToken has many nodes with its keys ranging from t1,t2,t3 ....t100 .

Now in my process many objects(of a class A) are being created( about 500).

These objects only checks the map to see whether a particular token is present as shown...

if( mapToken.find(T65) == mapToken.end() ){

cerr<< "The token is not valid "<<endl;

cout <<"token is valid" << endl;

keep in mind 100's of such objects want to do the same thing and can be at the same time too..

Now there are a different kind of objects created(say from class B) which has a function to delete a specific node from the 'mapToken' which is 'global'.



And it has a function to add new node too but we can keep it aside.

Question :

In real time there are hundreds of these objects who wants to access this mapToken container...some just checking for a token, some deleting a node which has a particular key.. THESE OBJECTS ARE NOT USING ANY ITERATOR AT ALL.. JUST the find and erase function that STL map gives..

Now Does the STL map takes care of how to handle these many simultaneous requests.

Is handling of the calls done one by one?

The case I am worried about:

It should not 'erase' a node when a 'find' is going on.

Ie one object is checking if t80 is present on the map.. When the find is the middle an ‘erase’ should not interrupt the ‘find’.

The STL map should be inherently taking care of this condition but I am not sure.
Nov 8 '06 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,916
If you are not sure then you will need to produce some sort of specific or case where you can prove that it is not happening correctly.
Nov 9 '06 #2

P: 9
If you are not sure then you will need to produce some sort of specific or case where you can prove that it is not happening correctly.

Mine is a single threaded process... so no matter how many objects are being created in real time , when every object is going for that single GLOBAL map. dont you u think the processor will allow this memory access sequentially only since this being a single threaded when one object is doing a 'map.find' , is ther any possibility that this object will be stopped mid way and another Object will be allowed to modify the map by 'map.erase'... this could have happened if these objects belong to different threads or process accessing a common memory area..
Nov 10 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.