<div dir="ltr">+1 from me.  I don&#39;t think anyone really wants the current readMVar semantics anyway, and if somebody really does they can define their own non-atomic readMVar.  Thanks for working on this!</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Jul 11, 2013 at 4:38 AM, Edward Z. Yang <span dir="ltr">&lt;<a href="mailto:ezyang@mit.edu" target="_blank">ezyang@mit.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Oh, found it.<br>
<div class="im HOEnZb"><br>
Excerpts from Austin Seipp&#39;s message of Wed Jul 10 12:28:48 -0700 2013:<br>
</div><div class="HOEnZb"><div class="h5">&gt; After reading some of the background and seeing this, +1 (Frankly, I<br>
&gt; didn&#39;t even know before this that readMVar had the race condition you<br>
&gt; described, and from my point of view, it should simply be fixed!)<br>
&gt;<br>
&gt; Also: If you add a small release note blurb for the changes `base`,<br>
&gt; that would be wonderful too. :)<br>
&gt;<br>
&gt; On Wed, Jul 10, 2013 at 4:20 AM, Edward Z. Yang &lt;<a href="mailto:ezyang@mit.edu">ezyang@mit.edu</a>&gt; wrote:<br>
&gt; &gt; GHC HEAD recently got a new primitive: atomicReadMVar#, which allows you<br>
&gt; &gt; to read MVars without first taking and then putting back (removing a<br>
&gt; &gt; nasty race where readMVar only works properly when there are no waiting<br>
&gt; &gt; putters).<br>
&gt; &gt;<br>
&gt; &gt; atomicReadMVar behaves differently from readMVar.  The key<br>
&gt; &gt; differences are:<br>
&gt; &gt;<br>
&gt; &gt;     - An atomicReadMVar op never causes an MVar to become &quot;empty&quot; at any point.<br>
&gt; &gt;       This means less programs deadlock now.<br>
&gt; &gt;<br>
&gt; &gt;     - An blocked atomicReadMVar is always served by the *first* putMVar<br>
&gt; &gt;       to arrive (it cuts to the head of the queue), whereas readMVar<br>
&gt; &gt;       obeyed the FIFO ordering.  This means this program behaves differently:<br>
&gt; &gt;<br>
&gt; &gt;         m &lt;- newEmptyMVar<br>
&gt; &gt;         forkIO $ takeMVar m<br>
&gt; &gt;         threadDelay 100<br>
&gt; &gt;         forkIO $ print =&lt;&lt; readMVar m {- atomicReadMVar m -}<br>
&gt; &gt;         threadDelay 100<br>
&gt; &gt;         putMVar m 1<br>
&gt; &gt;         putMVar m 2<br>
&gt; &gt;         -- readMVar: outputs 2<br>
&gt; &gt;         -- atomicReadMVar: outputs 1<br>
&gt; &gt;<br>
&gt; &gt;       It actually would not be too difficult to add support for atomicReadMVar<br>
&gt; &gt;       which *does* respect the FIFO ordering but I don&#39;t have a sense when<br>
&gt; &gt;       that would be useful.<br>
&gt; &gt;<br>
&gt; &gt; The general feeling Simon and I have is that everyone really wanted<br>
&gt; &gt; to make believe readMVar was atomicReadMVar, and so maybe we should<br>
&gt; &gt; break BC and make readMVar do the right thing.  But it is probably<br>
&gt; &gt; worth some discussion, and I entreat you to think about the second<br>
&gt; &gt; point more carefully.<br>
&gt; &gt;<br>
&gt; &gt; Thanks,<br>
&gt; &gt; Edward<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Libraries mailing list<br>
&gt; &gt; <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
&gt; &gt; <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
&gt;<br>
<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>