synchronized (this[.classinfo]) in druntime and phobos
Alex Rønne Petersen
alex at lycus.org
Tue May 29 05:26:02 PDT 2012
On 29-05-2012 14:19, Dmitry Olshansky wrote:
> On 29.05.2012 16:07, Regan Heath wrote:
>>
>> According to the docs here:
>> http://dlang.org/class.html#synchronized-functions
>>
>> A synchronized function locks "this" and as "this" is exposed
>> publicly... In the following code the "lock" statement and "synchronized
>> void bar" lock the same mutex.
>>
>> class Foo {
>> synchronized void bar() { ...statements... }
>> }
>>
>> void main()
>> {
>> Foo foo = new Foo();
>> lock(foo)
>> {
>> ...statements...
>> }
>> }
>>
>>> But locking on another class rather than something specifically
>>> intended as a mutex does seem to me like it's asking for trouble.
>
> I'd be darned but every Object in D has monitor fields. If I'm not
> mistaken it's the mutex you are looking for ;)
>
>
Indeed they do, and therefore each object must eat an entire word of
memory for questionable gain.
Generalized object monitors is the worst idea in programming language
and virtual machine design, ever.
--
Alex Rønne Petersen
alex at lycus.org
http://lycus.org
More information about the Digitalmars-d
mailing list