
Sebastian Redl wrote:
What makes me believe it is that there will ever only be one writer.
Your code does not enforce this in any way. Besides this it never is safe to access any shared data item from multiple threads, even if it is for reading only. The only exception is when you know for sure, that the access is atomic. The C++ standards does not give you any guarantees on this. (But work is in progess.) Also your code might suffer from another problem: What does guarantee that the thread has not already ended, when you are calling into signal_worker. i->second might point to released memory at this time. About volatile: while it might not hurt in your usage case, believing volatile is enough for multiprocessor is wrong. Volatile does not give you any guarantees on memory ordering. To summarize: Your suggested code might work on a specific platfform/compiler but is nonportable, and thus dangerous. If you absolutely need it, you should properly encapsulate it or mark it clearly as such. Roland