A monitor for every object

Sean Kelly sean at invisibleduck.org
Mon Feb 7 11:29:37 PST 2011


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.  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.


More information about the Digitalmars-d mailing list