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
a...@lycus.org
http://lycus.org

Reply via email to