On 18.01.2011 14:44, Richard Heck wrote:
On 01/18/2011 05:11 AM, Peter Kümmel wrote:
Now living with the locks in Graph, what about applying
a similar patch to have the const correctness.
I would change the patch so theConverters() will return
a const ref not only a ref:

If that's all that needs doing, and it works, then it looks good to me.

I guess the rule ought to be: Such global lists have only const access,
and all write access to mutable members must be synchronized. Yes?

No, you must also lock the const functions because the internal data could
be changed by a other thread calling a non-const function while a other
threads uses the data in a const data.

The only way to change this is to use a other algorithm:
http://en.wikipedia.org/wiki/Non-blocking_algorithm

Peter

Reply via email to