digitalmars.D - A monitor for every object
- bearophile (8/9) Feb 04 2011 I have found an interesting post by Scott Johnson in this Lambda the Ult...
- Mafi (6/15) Feb 04 2011 Please note that D has a syntax for such things (optimizations with
- Steven Schveighoffer (11/35) Feb 04 2011 D's monitors are lazily created, so there should be no issue with resour...
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= (9/11) Feb 04 2011 What happens if two threads attempt to create a monitor for the
- Robert Jacques (3/10) Feb 04 2011 Only the reference to the mutex is shared, so all you need in an atomic ...
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= (10/23) Feb 05 2011 op.
- Robert Jacques (9/27) Feb 05 2011 Yes, the beast exists and it's the basis for most lock-free programming ...
- Tomek =?UTF-8?B?U293acWEc2tp?= (9/17) Feb 04 2011 =20
- Tomek =?UTF-8?B?U293acWEc2tp?= (8/14) Feb 04 2011 to =20
- Sean Kelly (11/19) Feb 04 2011 assign =20
- Steven Schveighoffer (9/27) Feb 07 2011 Sean, I could have sworn that mutex can take over multiple objects'
- Robert Jacques (4/35) Feb 07 2011 Steve, you can always assign to an object's monitor variable manually. B...
- Steven Schveighoffer (5/46) Feb 07 2011 Sure, Mutex does this already. What I was simply asking is if it will
- Sean Kelly (2/11) Feb 07 2011 It'll work fine, so long as the monitor is a Mutex. If you want to shar...
- Steven Schveighoffer (8/25) Feb 07 2011 I think sharing a default monitor is not necessary, we can make do with ...
- Sean Kelly (2/35) Feb 07 2011 Now that you mention it, I think TDPL describes a call like setMonitor()...
- Kagamin (4/6) Feb 04 2011 C# has this design too, but locking a common object directly is not used...
- Kagamin (2/8) Feb 04 2011 Ah, I forgot to say, that C# has a sort of guideline to lock the SyncRoo...
- bearophile (5/7) Feb 04 2011 I'd like to know in a normal object oriented program how much memory thi...
- Robert Jacques (5/13) Feb 04 2011 1 word per object, assuming a uniform distribution of object sizes. Yes...
- bearophile (5/8) Feb 04 2011 One more thing.
- Robert Jacques (5/22) Feb 04 2011 Well, in DMD the monitor is null prior to use, so I'm not sure what's
- spir (9/12) Feb 05 2011 For the non-sorcerers following the thread, would someone explain in a f...
- Steven Schveighoffer (28/38) Feb 07 2011 A monitor is used for concurrency. Essentially, it is a mutex (or
- Steven Schveighoffer (5/14) Feb 07 2011 I may be wrong on this one, it looks like from the docs a mutex can only...
- Robert Jacques (20/44) Feb 04 2011 Hmm... Well, I'd recommend making @nomonitor the default and then only
I have found an interesting post by Scott Johnson in this Lambda the Ultimate thread: http://lambda-the-ultimate.org/node/724#comment-6621 He says:9th circle: Concurrent mutable state. The obnoxious practice of mutating shared state from multiple threads of control, leading into a predictable cycle of race conditions, deadlocks, and other assorted misbehavior from which there is no return. And if a correct solution (for synchronization) is found for a given program, chances are any substantial change to the program will make it incorrect again. But you won't find it, instead your customer will. Despite that, reams of code (and TONS of middleware) has been written to try and make this tractable. And don't get me started on a certain programming language which starts with "J" that saw fit to make EVERY object have its very own monitor....<This is just one quotation, but I have found similar comments four or five other times around the Web. So is the design choice of copying this part of the Java design inside D good? I'd like opinions on this topic. Recently I have suggested an optional nomonitor annotation for D classes (to optionally remove a word from class instances and to reduce class instantiation overhead a bit). Another option is doing the opposite, and defining a withmonitor annotation where you want a class to have a monitor. Bye, bearophile
Feb 04 2011
Am 04.02.2011 13:26, schrieb bearophile:I have found an interesting post by Scott Johnson in this Lambda the Ultimate thread: http://lambda-the-ultimate.org/node/724#comment-6621 He says:Please note that D has a syntax for such things (optimizations with little behavior change). It called 'pragma'. Exchange nomonitor with pragma(nomonitor) and I'm for your idea. pragma looks and feels better IMO. Mafi PS: cant see any ttributes more :(9th circle: Concurrent mutable state. The obnoxious practice of mutating shared state from multiple threads of control, leading into a predictable cycle of race conditions, deadlocks, and other assorted misbehavior from which there is no return. And if a correct solution (for synchronization) is found for a given program, chances are any substantial change to the program will make it incorrect again. But you won't find it, instead your customer will. Despite that, reams of code (and TONS of middleware) has been written to try and make this tractable. And don't get me started on a certain programming language which starts with "J" that saw fit to make EVERY object have its very own monitor....<This is just one quotation, but I have found similar comments four or five other times around the Web. So is the design choice of copying this part of the Java design inside D good? I'd like opinions on this topic. Recently I have suggested an optional nomonitor annotation for D classes (to optionally remove a word from class instances and to reduce class instantiation overhead a bit). Another option is doing the opposite, and defining a withmonitor annotation where you want a class to have a monitor. Bye, bearophile
Feb 04 2011
On Fri, 04 Feb 2011 07:26:22 -0500, bearophile <bearophileHUGS lycos.com> wrote:I have found an interesting post by Scott Johnson in this Lambda the Ultimate thread: http://lambda-the-ultimate.org/node/724#comment-6621 He says:D's monitors are lazily created, so there should be no issue with resource allocation. If you don't ever lock an object instance, it's not going to consume any resources. Most of the time the extra word isn't noticed because the memory size of a class is usually not exactly a power of 2. 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 -Steve9th circle: Concurrent mutable state. The obnoxious practice of mutating shared state from multiple threads of control, leading into a predictable cycle of race conditions, deadlocks, and other assorted misbehavior from which there is no return. And if a correct solution (for synchronization) is found for a given program, chances are any substantial change to the program will make it incorrect again. But you won't find it, instead your customer will. Despite that, reams of code (and TONS of middleware) has been written to try and make this tractable. And don't get me started on a certain programming language which starts with "J" that saw fit to make EVERY object have its very own monitor....<This is just one quotation, but I have found similar comments four or five other times around the Web. So is the design choice of copying this part of the Java design inside D good? I'd like opinions on this topic. Recently I have suggested an optional nomonitor annotation for D classes (to optionally remove a word from class instances and to reduce class instantiation overhead a bit). Another option is doing the opposite, and defining a withmonitor annotation where you want a class to have a monitor.
Feb 04 2011
Steven Schveighoffer wrote:D's monitors are lazily created, so there should be no issue with resource allocation.=20What happens if two threads attempt to create a monitor for the same object at the same time? Is there a global lock to avoid race conditions in this case? Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Feb 04 2011
On Fri, 04 Feb 2011 17:23:35 -0500, Jérôme M. Berger <jeberger free.fr> wrote:Steven Schveighoffer wrote:Only the reference to the mutex is shared, so all you need in an atomic op.D's monitors are lazily created, so there should be no issue with resource allocation.What happens if two threads attempt to create a monitor for the same object at the same time? Is there a global lock to avoid race conditions in this case? Jerome
Feb 04 2011
Robert Jacques wrote:On Fri, 04 Feb 2011 17:23:35 -0500, J=C3=A9r=C3=B4me M. Berger <jeberge=r free.fr>wrote: =20op. This requires an atomic "if (a is null) a =3D b;". I did not know that such a beast existed. Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.frSteven Schveighoffer wrote:=20 Only the reference to the mutex is shared, so all you need in an atomic=D's monitors are lazily created, so there should be no issue with resource allocation.What happens if two threads attempt to create a monitor for the same object at the same time? Is there a global lock to avoid race conditions in this case? Jerome
Feb 05 2011
On Sat, 05 Feb 2011 03:00:31 -0500, Jérôme M. Berger <jeberger free.fr> wrote:Robert Jacques wrote:Yes, the beast exists and it's the basis for most lock-free programming as well as lock implementations. It's generally known as compare and swap or CAS (see http://en.wikipedia.org/wiki/Compare_and_swap and core.atomic.cas). There's also another atomic primitive called Load-Link/Store-Conditional, which is available an several non-x86 architectures (ARM, PowerPC, etc) and is generally considered a more powerful primitive than CAS.On Fri, 04 Feb 2011 17:23:35 -0500, Jérôme M. Berger <jeberger free.fr> wrote:This requires an atomic "if (a is null) a = b;". I did not know that such a beast existed. JeromeSteven Schveighoffer wrote:Only the reference to the mutex is shared, so all you need in an atomic op.D's monitors are lazily created, so there should be no issue with resource allocation.What happens if two threads attempt to create a monitor for the same object at the same time? Is there a global lock to avoid race conditions in this case? Jerome
Feb 05 2011
Steven Schveighoffer napisa=C5=82:D's monitors are lazily created, so there should be no issue with resourc=e =20allocation. If you don't ever lock an object instance, it's not going to==20consume any resources. Most of the time the extra word isn't noticed =20 because the memory size of a class is usually not exactly a power of 2.Except when you put'em in an array. Could happen.D also allows you to replace it's monitor with a custom monitor object =20 (i.e. core.sync.Mutex) so you can have more control over the mutex, assig=n =20the same mutex to multiple objects, use conditions, etc. It's much more ==20I didn't know, thx. Where is it documented? --=20 Tomek
Feb 04 2011
Tomek Sowi=C5=84ski napisa=C5=82:rce =20D's monitors are lazily created, so there should be no issue with resou=to =20allocation. If you don't ever lock an object instance, it's not going ==20consume any resources. Most of the time the extra word isn't noticed ==20because the memory size of a class is usually not exactly a power of 2.==20 Except when you put'em in an array. Could happen.Sorry, for some reason I thought the mutex is on the stack. --=20 Tomek
Feb 04 2011
On Feb 4, 2011, at 3:06 PM, Tomek Sowi=C5=84ski wrote:Steven Schveighoffer napisa=C5=82: =20object =20D also allows you to replace it's monitor with a custom monitor =assign =20(i.e. core.sync.Mutex) so you can have more control over the mutex, =more =20the same mutex to multiple objects, use conditions, etc. It's much =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.==20 I didn't know, thx. Where is it documented?
Feb 04 2011
On Fri, 04 Feb 2011 18:29:08 -0500, Sean Kelly <sean invisibleduck.org> wrote:On Feb 4, 2011, at 3:06 PM, Tomek Sowiński wrote: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? -SteveSteven Schveighoffer napisał: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.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 moreI didn't know, thx. Where is it documented?
Feb 07 2011
On Mon, 07 Feb 2011 08:20:20 -0500, Steven Schveighoffer <schveiguy yahoo.com> wrote:On Fri, 04 Feb 2011 18:29:08 -0500, Sean Kelly <sean invisibleduck.org> 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.On Feb 4, 2011, at 3:06 PM, Tomek Sowiński wrote: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? -SteveSteven Schveighoffer napisał: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.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 moreI didn't know, thx. Where is it documented?
Feb 07 2011
On Mon, 07 Feb 2011 10:33:29 -0500, Robert Jacques <sandford jhu.edu> wrote:On Mon, 07 Feb 2011 08:20:20 -0500, Steven Schveighoffer <schveiguy yahoo.com> wrote:Sure, Mutex does this already. What I was simply asking is if it will blow up or not :) -SteveOn Fri, 04 Feb 2011 18:29:08 -0500, Sean Kelly <sean invisibleduck.org> 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.On Feb 4, 2011, at 3:06 PM, Tomek Sowiński wrote: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? -SteveSteven Schveighoffer napisał: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.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 moreI didn't know, thx. Where is it documented?
Feb 07 2011
Steven Schveighoffer Wrote:On Mon, 07 Feb 2011 10:33:29 -0500, Robert Jacques <sandford jhu.edu> wrote: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.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 :)
Feb 07 2011
On Mon, 07 Feb 2011 14:29:37 -0500, Sean Kelly <sean invisibleduck.org> wrote:Steven Schveighoffer Wrote:I think sharing a default monitor is not necessary, we can make do with Mutex.On Mon, 07 Feb 2011 10:33:29 -0500, Robert Jacques <sandford jhu.edu> wrote: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.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 :)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
Feb 07 2011
Steven Schveighoffer Wrote:On Fri, 04 Feb 2011 18:29:08 -0500, Sean Kelly <sean invisibleduck.org> wrote: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.On Feb 4, 2011, at 3:06 PM, Tomek Sowiński wrote: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?Steven Schveighoffer napisał: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.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 moreI didn't know, thx. Where is it documented?
Feb 07 2011
bearophile Wrote:a certain programming language which starts with "J" that saw fit to make EVERY object have its very own monitor....< So is the design choice of copying this part of the Java design inside D good? I'd like opinions on this topic.used to create separate object for locking, the property to access it being called SyncRoot. It's implementation is a usual combination of new object() and CompareExchange. http://msdn.microsoft.com/en-us/library/system.collections.icollection.syncroot.aspx I don't feel the need for locking functionality in Object, this is usually a major design decision for a couple of classes - even in a large project. After all, after this design decision you should also carefully implement the locking in the code using the object, this will take some time, so it can't be a light-minded decision.
Feb 04 2011
Kagamin Wrote:bearophile Wrote:instead of collection itself.a certain programming language which starts with "J" that saw fit to make EVERY object have its very own monitor....< So is the design choice of copying this part of the Java design inside D good? I'd like opinions on this topic.used to create separate object for locking, the property to access it being called SyncRoot. It's implementation is a usual combination of new object() and CompareExchange.
Feb 04 2011
Steven Schveighoffer:Most of the time the extra word isn't noticed because the memory size of a class is usually not exactly a power of 2.I'd like to know in a normal object oriented program how much memory this design actually wastes. Thank you to you and Kagamin for your answers, bye, bearophile
Feb 04 2011
On Fri, 04 Feb 2011 16:02:55 -0500, bearophile <bearophileHUGS lycos.com> wrote:Steven Schveighoffer:1 word per object, assuming a uniform distribution of object sizes. Yes, _most_ objects aren't affected, but the ones that are make up for the difference by using twice the ram.Most of the time the extra word isn't noticed because the memory size of a class is usually not exactly a power of 2.I'd like to know in a normal object oriented program how much memory this design actually wastes. Thank you to you and Kagamin for your answers, bye, bearophile
Feb 04 2011
Steven Schveighoffer:D's monitors are lazily created, so there should be no issue with resource allocation. If you don't ever lock an object instance, it's not going to consume any resources.One more thing. I remember working with LDC some developers to speed up the stack (scope) allocation of class instances (in D1), and I remember one of the slows down comes from the need to call something that sets the monitor pointer. This call to the runtime was never inlined by ldc, so it was a significant cost compared to similar class instances stack allocated by the JavaVM through escape analysis. So moniror management has a cost in LDC and I presume in DMD too, unless some inlining here will be somehow forced. Bye, bearophile
Feb 04 2011
On Fri, 04 Feb 2011 16:07:02 -0500, bearophile <bearophileHUGS lycos.com> wrote:Steven Schveighoffer:Well, in DMD the monitor is null prior to use, so I'm not sure what's happening in LDC, but I'd doubt DMD is making such a call just to set it to 0.D's monitors are lazily created, so there should be no issue with resource allocation. If you don't ever lock an object instance, it's not going to consume any resources.One more thing. I remember working with LDC some developers to speed up the stack (scope) allocation of class instances (in D1), and I remember one of the slows down comes from the need to call something that sets the monitor pointer. This call to the runtime was never inlined by ldc, so it was a significant cost compared to similar class instances stack allocated by the JavaVM through escape analysis. So moniror management has a cost in LDC and I presume in DMD too, unless some inlining here will be somehow forced. Bye, bearophile
Feb 04 2011
Steven Schveighoffer:D's monitors are lazily created, so there should be no issue with resource allocation. If you don't ever lock an object instance, it's not going to consume any resources.For the non-sorcerers following the thread, would someone explain in a few words what it actually means, conceptually and concretely, for an object to be its own monitor. (searches online have brought me nothing relevant) Denis -- _________________ vita es estrany spir.wikidot.com
Feb 05 2011
On Sat, 05 Feb 2011 05:51:35 -0500, spir <denis.spir gmail.com> wrote:Steven Schveighoffer:A monitor is used for concurrency. Essentially, it is a mutex (or critical section on Windows). When you do this: class C { synchronized void foo() {} } The synchronized keyword means a call to foo will lock the embedded monitor before calling it. The meaning of an 'object being its own monitor' is just that the monitor for operations on an object is conceptually the object itself (even though it's technically a hidden member of the object). This model has some very bad drawbacks, because it encourages you to use an object to lock an operation on itself when most cases, you want more coarse mutexes (mutexes should be tied to entire concepts, not just to individual objects). With D, you can alleviate this somewhat by specifying a specific monitor for an object. To explain my statement in real-world terms, the monitor is essentially a resource handle (on linux, this is a pthread_mutext_t) that begins life as null. When an object is locked for the very first time, some low-level atomic code checks to see if the monitor is allocated and if not, creates a pthread mutex and assigns it to that hidden monitor field. Once the monitor is created, it's used from now on. What I meant by lazy creation is that simply creating an object doesn't also consume a mutex resource + degrade performance. It's only on the first lock that you have to worry about it. -SteveD's monitors are lazily created, so there should be no issue with resource allocation. If you don't ever lock an object instance, it's not going to consume any resources.For the non-sorcerers following the thread, would someone explain in a few words what it actually means, conceptually and concretely, for an object to be its own monitor. (searches online have brought me nothing relevant)
Feb 07 2011
On Mon, 07 Feb 2011 07:48:53 -0500, Steven Schveighoffer <schveiguy yahoo.com> wrote:The meaning of an 'object being its own monitor' is just that the monitor for operations on an object is conceptually the object itself (even though it's technically a hidden member of the object). This model has some very bad drawbacks, because it encourages you to use an object to lock an operation on itself when most cases, you want more coarse mutexes (mutexes should be tied to entire concepts, not just to individual objects). With D, you can alleviate this somewhat by specifying a specific monitor for an object.I may be wrong on this one, it looks like from the docs a mutex can only be assigned to exactly one object. But I've asked Sean to clarify. -Steve
Feb 07 2011
On Fri, 04 Feb 2011 07:26:22 -0500, bearophile <bearophileHUGS lycos.com> wrote:I have found an interesting post by Scott Johnson in this Lambda the Ultimate thread: http://lambda-the-ultimate.org/node/724#comment-6621 He says:Hmm... Well, I'd recommend making nomonitor the default and then only annotate certain classes withmonitor, although I'd prefer a different keyword, say 'shared'. Oh, wait a second. *sigh* Every since it was decided that a class couldn't contain both shared and non-shared methods/fields I've been expecting that the monitor and support for synchronized methods would be removed from Object or at least from Object's spec. But this is likely a high-cost/low-gain optimization and a lot of things regarding shared/immutable classes need to be fixed before it can happen. I do think it should happen, not so much for the word of memory, but in order to prevent objects not designed to be shared from being shared. Which is what the 9th circle is talking about. One of the cool thing about D's monitors, is that by manually setting them, you can protect multiple objects with a single monitor. So, for a set of interwoven objects (i.e. trees, etc) you're not acquiring a new lock every method call and you are not going to have an internal deadlock/race. This is actually the essential runtime feature of many ownership systems. (Although, without an actual ownership-type system you can't elide synchronization entirely)9th circle: Concurrent mutable state. The obnoxious practice of mutating shared state from multiple threads of control, leading into a predictable cycle of race conditions, deadlocks, and other assorted misbehavior from which there is no return. And if a correct solution (for synchronization) is found for a given program, chances are any substantial change to the program will make it incorrect again. But you won't find it, instead your customer will. Despite that, reams of code (and TONS of middleware) has been written to try and make this tractable. And don't get me started on a certain programming language which starts with "J" that saw fit to make EVERY object have its very own monitor....<This is just one quotation, but I have found similar comments four or five other times around the Web. So is the design choice of copying this part of the Java design inside D good? I'd like opinions on this topic. Recently I have suggested an optional nomonitor annotation for D classes (to optionally remove a word from class instances and to reduce class instantiation overhead a bit). Another option is doing the opposite, and defining a withmonitor annotation where you want a class to have a monitor.
Feb 04 2011