<div class="gmail_quote">On Sun, Jun 3, 2012 at 4:39 PM, deadalnix <span dir="ltr"><<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">

Le 03/06/2012 21:40, Andrew Wiley a écrit :<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div class="im">
On Sun, Jun 3, 2012 at 12:29 PM, deadalnix <<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a><br></div><div><div class="h5">
<mailto:<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a>>> wrote:<br>
<br>
    Le 01/06/2012 22:55, Sean Kelly a écrit :<br>
<br>
        On Jun 1, 2012, at 5:26 AM, deadalnix wrote:<br>
<br>
<br>
            The main drawback is the same as opApply : return (and<br>
            break/continue but it is less relevant for opSynchronized).<br>
            Solution to this problem have been proposed in the past<br>
            using compiler and stack magic.<br>
<br>
            It open door for stuff like :<br>
            ReadWriteLock rw;<br>
            synchronized(rw.read) {<br>
<br>
            }<br>
<br>
            synchronized(rw.write) {<br>
<br>
            }<br>
<br>
<br>
        Opens the door?  This works today exactly as outlined above.  Or<br>
        am I missing a part of your argument?<br>
<br>
            And many types of lock : spin lock, interprocesses locks,<br>
            semaphores, . . . And all can be used with the synchronized<br>
            syntax, and without exposing locking and unlocking primitives.<br>
<br>
<br>
        All works today.<br>
<br>
<br>
    Unless you do some monitor magic, it doesn't.<br>
<br></div></div><div class="im">
Yes, it does.<br>
-----<br>
class Something {<br>
     private:<br>
         ReadWriteLock _rw;<br>
     public:<br>
         this() {<br>
             _rw = new ReadWriteLock();<br>
         }<br>
         void doSomething() shared {<br>
             synchronized(_rw.read) {<br>
                 // do things<br>
             }<br>
         }<br>
}<br>
-----<br>
I've used this pattern in code. There might be some casting required<br>
because the core synchronization primitives haven't been updated to use<br>
shared yet.<br>
</div></blockquote>
<br>
And where is that ReadWriteLock ?<br>
</blockquote></div><div> </div><div>On the GC heap, just like the Monitor object pointed to by __monitor if you mark a method or class as synchronized.<br></div>