A monitor for every object

Steven Schveighoffer schveiguy at yahoo.com
Mon Feb 7 11:34:02 PST 2011


On Mon, 07 Feb 2011 14:29:37 -0500, Sean Kelly <sean at invisibleduck.org>  
wrote:

> Steven Schveighoffer Wrote:
>
>> On Mon, 07 Feb 2011 10:33:29 -0500, Robert Jacques <sandford at jhu.edu>
>> wrote:
>> >
>> > Steve, you can always assign to an object's monitor variable manually.
>> > But adding this functionality to Mutex's and Object's API would be
>> > appreciated.
>>
>> Sure, Mutex does this already.  What I was simply asking is if it will
>> blow up or not :)
>
> It'll work fine, so long as the monitor is a Mutex.  If you want to  
> share the default monitor, that will require some work, because the  
> instance is manually allocated.

I think sharing a default monitor is not necessary, we can make do with  
Mutex.

> Oh, another issue with using Mutex as an object monitor is that it's  
> allocated on the GC heap, so a synchronized block in the object's dtor  
> could fail.  All the usual workarounds apply--just something to be aware  
> of.

It might be a good idea to identify these limitations (the signal one and  
this one) in the docs if they aren't already...

And thanks for looking at this.

-Steve


More information about the Digitalmars-d mailing list