Steven Schveighoffer Wrote: > On Fri, 04 Feb 2011 18:29:08 -0500, Sean Kelly <[email protected]> > wrote: > > > On Feb 4, 2011, at 3:06 PM, Tomek SowiÅski wrote: > > > >> Steven Schveighoffer napisaÅ: > >> > >>> D also allows you to replace it's monitor with a custom monitor object > >>> (i.e. core.sync.Mutex) so you can have more control over the mutex, > >>> assign > >>> the same mutex to multiple objects, use conditions, etc. It's much > >>> more > >>> flexible than Java or C# IMO. > >> > >> I didn't know, thx. Where is it documented? > > > > Only in the docs for the Mutex ctor here: > > > > http://www.digitalmars.com/d/2.0/phobos/core_sync_mutex.html > > > > By the way, when using Mutex as an object monitor you currently can't > > attach dispose event handlers to the object (ie. via std.signals). That > > functionality is only supported by the default monitor. I've considered > > changing this, but doing so imposes some weird requirements on the > > creators of an external object monitor, like Mutex. > > Sean, I could have sworn that mutex can take over multiple objects' > monitors. This would be highly desirable in a complex structure where > members of an object should use the same mutex for synchronized calls. > > But looking at the docs once again, it looks like it can only be the > monitor for one object (as the target object is accepted only on > construction). Is that a limitation we cannot remove?
Now that you mention it, I think TDPL describes a call like setMonitor() that's supposed to do this, and I just forgot to implement it. There's no technical barrier. It's simply a matter of assigning the monitor reference to the correct part of the Mutex instance.
