synchronized (this[.classinfo]) in druntime and phobos

Alex Rønne Petersen alex at lycus.org
Wed May 30 11:38:41 PDT 2012


On 30-05-2012 20:25, Andrei Alexandrescu wrote:
> On 5/30/12 10:28 AM, Alex Rønne Petersen wrote:
>> On 30-05-2012 19:12, Andrei Alexandrescu wrote:
>>> On 5/30/12 9:23 AM, Alex Rønne Petersen wrote:
>>>> On 30-05-2012 18:14, Andrei Alexandrescu wrote:
>>>>> This is news to me. How do you publicly access the mutex of a
>>>>> synchronized class object?
>>>>
>>>> Generally in two ways:
>>>>
>>>> 1) synchronized (obj)
>>>
>>> This is not accessing the mutex for arbitrary operations.
>>
>> No, it is indeed not. You didn't explicitly say you wanted to do
>> "arbitrary operations", so I assumed that by accessing the mutex you
>> meant doing the only two things that are sensible for a mutex: Locking
>> and unlocking it. What else would you want to do?
>
> For example, locking it in one function and unlocking it in another.
> This is impossible with synchronized(obj).
>
> To summarize, the synchronized(obj) operation is not exposing the mutex,
> only manipulate it in a specific way.

It clearly exposes it *enough* to cause potential for deadlocks by 
manipulating it in this specific way, which is what this is all about.

I don't think arguing about what "exposed" means in this specific 
context (or perhaps in general?) or what levels of manipulation justify 
the use of the term "expose" will get the discussion anywhere...

>
>
> Andrei

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d mailing list