Synchronized const methods

Tomek Sowiński just at ask.me
Sat Jun 12 01:16:36 PDT 2010


Dnia 12-06-2010 o 09:28:58 Jérôme M. Berger <jeberger at free.fr> napisał(a):

> Daniel Keep wrote:
>> immutable means "no one can modify this."
>>
>> const means "someone might be able to modify this, but not you can't."
>
> 	So?
>
> 	Basically, what the OP said, is that we need readers-writer locks
> [1]. A const synchronized method would use the read lock (and
> therefore several threads can access the same object through *const*
> synchronized methods simultaneously), but a non const synchronized
> method would use the read-write lock (which would prevent anyone
> else from accessing the same object through a synchronized method,
> be it const or not).
>
> 		Jerome
>
> [1] http://en.wikipedia.org/wiki/Readers-writer_lock

Exactly.

How is synchronization implemented in D right now? Would there be room to  
let the lock distinguish reads & writes?


Tomek


More information about the Digitalmars-d-learn mailing list