<div class="gmail_quote">On Sun, Jun 3, 2012 at 12:29 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 01/06/2012 22:55, Sean Kelly 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 Jun 1, 2012, at 5:26 AM, deadalnix wrote:<br>
</div><div class="im"><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">
<br>
The main drawback is the same as opApply : return (and break/continue but it is less relevant for opSynchronized). Solution to this problem have been proposed in the past 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>
</blockquote>
<br></div><div class="im">
Opens the door?  This works today exactly as outlined above.  Or am I missing a part of your argument?<br>
<br>
</div><div class="im"><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">
And many types of lock : spin lock, interprocesses locks, semaphores, . . . And all can be used with the synchronized syntax, and without exposing locking and unlocking primitives.<br>
</blockquote>
<br></div>
All works today.<br>
</blockquote>
<br>
Unless you do some monitor magic, it doesn't.<br>
</blockquote><div> </div><div>Yes, it does. </div><div>-----</div><div>class Something {</div><div>    private:</div></div><div>        ReadWriteLock _rw;</div><div>    public:</div><div>        this() {</div><div>            _rw = new ReadWriteLock();</div>

<div>        }</div><div>        void doSomething() shared {</div><div>            synchronized(_rw.read) {</div><div>                // do things</div><div>            }</div><div>        }</div><div>}</div><div>-----</div>

<div> </div><div>I've used this pattern in code. There might be some casting required because the core synchronization primitives haven't been updated to use shared yet.<br></div>