<div dir="ltr">Interesting. Is the non-blocking alternative to change the &quot;while...&quot; to &quot;if (!_eof)&quot;? There&#39;s no problem with writing _buffer when hasRemaining() is true, is there?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 16, 2014 at 11:03 PM, Stuart Douglas <span dir="ltr">&lt;<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
1068            // Read from stream until buffer full or EOF<br>
1069            _buffer.clear();<br>
1070            while (_buffer.hasRemaining() &amp;&amp; !_eof)<br>
1071              _eof = (_in.read(_buffer)) &lt;  0;<br>
<br>
That pattern for reading from the stream only works for blocking IO. If you are using a non blocking channel this will basically wait in a busy loop till data becomes available.<br>
<br>
Stuart<br>
<br>
Jim Crossley wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Thanks, Jason. To me, the Jetty code looks like it&#39;s doing pretty much<br>
what Stuart told me to do. Can you tell me which part exactly assumes<br>
the blocking behavior so I can relay that to the Pedestal guys?<br>
<br>
On Tue, Sep 16, 2014 at 10:33 PM, Jason T. Greene &lt;<a href="mailto:jgreene@redhat.com" target="_blank">jgreene@redhat.com</a><br></span><span class="">
&lt;mailto:<a href="mailto:jgreene@redhat.com" target="_blank">jgreene@redhat.com</a>&gt;&gt; wrote:<br>
<br>
<br>
<br>
    Sent from my iPhone<br>
<br>
    &gt;  On Sep 16, 2014, at 8:19 PM, Jim Crossley &lt;<a href="mailto:jim@crossleys.org" target="_blank">jim@crossleys.org</a><br></span><span class="">
    &lt;mailto:<a href="mailto:jim@crossleys.org" target="_blank">jim@crossleys.org</a>&gt;&gt; wrote:<br>
    &gt;<br>
    &gt;  Is this an async or a blocking transfer? The problem with<br>
    &gt;  &gt; ReadableByteChannel is that it can be a blocking channel, and as a<br>
    &gt;  &gt; result reading from it in the IO thread will result in crappy<br>
    &gt;  &gt; performance.<br>
    &gt;<br>
    &gt;  Because of the way they&#39;re using it (with Clojure&#39;s core.async<br>
    library)<br>
    &gt;  I expect the transfer to be async, but I&#39;ll verify that with them.<br>
<br>
    I just looked at the Jetty impl, and the code assumes blocking<br>
    behavior with that method. Anything using it will be blocking reads<br>
    with non blocking writes.<br>
<br>
<br>
</span></blockquote>
</blockquote></div><br></div>