blob: be34d12ee23f69d0228b94643b939b9d037c7761 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_92) on Thu Jun 07 14:26:27 EDT 2018 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>WriteFlusher (Jetty :: Project 9.3.24.v20180605 API)</title>
<meta name="date" content="2018-06-07">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="WriteFlusher (Jetty :: Project 9.3.24.v20180605 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":6,"i7":10,"i8":10,"i9":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/WriteFlusher.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/eclipse/jetty/io/SelectorManager.html" title="class in org.eclipse.jetty.io"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../org/eclipse/jetty/io/WriterOutputStream.html" title="class in org.eclipse.jetty.io"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/eclipse/jetty/io/WriteFlusher.html" target="_top">Frames</a></li>
<li><a href="WriteFlusher.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.eclipse.jetty.io</div>
<h2 title="Class WriteFlusher" class="title">Class WriteFlusher</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.eclipse.jetty.io.WriteFlusher</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public abstract class <span class="typeNameLabel">WriteFlusher</span>
extends java.lang.Object</pre>
<div class="block">A Utility class to help implement <a href="../../../../org/eclipse/jetty/io/EndPoint.html#write-org.eclipse.jetty.util.Callback-java.nio.ByteBuffer...-"><code>EndPoint.write(Callback, ByteBuffer...)</code></a> by calling
<a href="../../../../org/eclipse/jetty/io/EndPoint.html#flush-java.nio.ByteBuffer...-"><code>EndPoint.flush(ByteBuffer...)</code></a> until all content is written.
The abstract method <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onIncompleteFlush--"><code>onIncompleteFlush()</code></a> is called when not all content has been written after a call to
flush and should organize for the <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#completeWrite--"><code>completeWrite()</code></a> method to be called when a subsequent call to flush
should be able to make more progress.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier</th>
<th class="colLast" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#WriteFlusher-org.eclipse.jetty.io.EndPoint-">WriteFlusher</a></span>(<a href="../../../../org/eclipse/jetty/io/EndPoint.html" title="interface in org.eclipse.jetty.io">EndPoint</a>&nbsp;endPoint)</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#completeWrite--">completeWrite</a></span>()</code>
<div class="block">Complete a write that has not completed and that called <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onIncompleteFlush--"><code>onIncompleteFlush()</code></a> to request a call to this
method when a call to <a href="../../../../org/eclipse/jetty/io/EndPoint.html#flush-java.nio.ByteBuffer...-"><code>EndPoint.flush(ByteBuffer...)</code></a> is likely to be able to progress.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>protected java.nio.ByteBuffer[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#flush-java.nio.ByteBuffer:A-">flush</a></span>(java.nio.ByteBuffer[]&nbsp;buffers)</code>
<div class="block">Flushes the buffers iteratively until no progress is made.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#isCallbackNonBlocking--">isCallbackNonBlocking</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#isInProgress--">isInProgress</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onClose--">onClose</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onFail-java.lang.Throwable-">onFail</a></span>(java.lang.Throwable&nbsp;cause)</code>
<div class="block">Notify the flusher of a failure</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>protected abstract void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onIncompleteFlush--">onIncompleteFlush</a></span>()</code>
<div class="block">Abstract call to be implemented by specific WriteFlushers.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#toStateString--">toStateString</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#toString--">toString</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#write-org.eclipse.jetty.util.Callback-java.nio.ByteBuffer...-">write</a></span>(<a href="../../../../org/eclipse/jetty/util/Callback.html" title="interface in org.eclipse.jetty.util">Callback</a>&nbsp;callback,
java.nio.ByteBuffer...&nbsp;buffers)</code>
<div class="block">Tries to switch state to WRITING.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="WriteFlusher-org.eclipse.jetty.io.EndPoint-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>WriteFlusher</h4>
<pre>protected&nbsp;WriteFlusher(<a href="../../../../org/eclipse/jetty/io/EndPoint.html" title="interface in org.eclipse.jetty.io">EndPoint</a>&nbsp;endPoint)</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="isCallbackNonBlocking--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isCallbackNonBlocking</h4>
<pre>public&nbsp;boolean&nbsp;isCallbackNonBlocking()</pre>
</li>
</ul>
<a name="onIncompleteFlush--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>onIncompleteFlush</h4>
<pre>protected abstract&nbsp;void&nbsp;onIncompleteFlush()</pre>
<div class="block">Abstract call to be implemented by specific WriteFlushers. It should schedule a call to <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#completeWrite--"><code>completeWrite()</code></a>
or <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onFail-java.lang.Throwable-"><code>onFail(Throwable)</code></a> when appropriate.</div>
</li>
</ul>
<a name="write-org.eclipse.jetty.util.Callback-java.nio.ByteBuffer...-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>write</h4>
<pre>public&nbsp;void&nbsp;write(<a href="../../../../org/eclipse/jetty/util/Callback.html" title="interface in org.eclipse.jetty.util">Callback</a>&nbsp;callback,
java.nio.ByteBuffer...&nbsp;buffers)
throws java.nio.channels.WritePendingException</pre>
<div class="block">Tries to switch state to WRITING. If successful it writes the given buffers to the EndPoint. If state transition
fails it'll fail the callback.
If not all buffers can be written in one go it creates a new <code>PendingState</code> object to preserve the state
and then calls <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onIncompleteFlush--"><code>onIncompleteFlush()</code></a>. The remaining buffers will be written in <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#completeWrite--"><code>completeWrite()</code></a>.
If all buffers have been written it calls callback.complete().</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>callback</code> - the callback to call on either failed or complete</dd>
<dd><code>buffers</code> - the buffers to flush to the endpoint</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.nio.channels.WritePendingException</code> - if unable to write due to prior pending write</dd>
</dl>
</li>
</ul>
<a name="completeWrite--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>completeWrite</h4>
<pre>public&nbsp;void&nbsp;completeWrite()</pre>
<div class="block">Complete a write that has not completed and that called <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onIncompleteFlush--"><code>onIncompleteFlush()</code></a> to request a call to this
method when a call to <a href="../../../../org/eclipse/jetty/io/EndPoint.html#flush-java.nio.ByteBuffer...-"><code>EndPoint.flush(ByteBuffer...)</code></a> is likely to be able to progress.
It tries to switch from PENDING to COMPLETING. If state transition fails, then it does nothing as the callback
should have been already failed. That's because the only way to switch from PENDING outside this method is
<a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onFail-java.lang.Throwable-"><code>onFail(Throwable)</code></a> or <a href="../../../../org/eclipse/jetty/io/WriteFlusher.html#onClose--"><code>onClose()</code></a></div>
</li>
</ul>
<a name="flush-java.nio.ByteBuffer:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>flush</h4>
<pre>protected&nbsp;java.nio.ByteBuffer[]&nbsp;flush(java.nio.ByteBuffer[]&nbsp;buffers)
throws java.io.IOException</pre>
<div class="block">Flushes the buffers iteratively until no progress is made.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>buffers</code> - The buffers to flush</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The unflushed buffers, or null if all flushed</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if unable to flush</dd>
</dl>
</li>
</ul>
<a name="onFail-java.lang.Throwable-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>onFail</h4>
<pre>public&nbsp;boolean&nbsp;onFail(java.lang.Throwable&nbsp;cause)</pre>
<div class="block">Notify the flusher of a failure</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>cause</code> - The cause of the failure</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the flusher passed the failure to a <a href="../../../../org/eclipse/jetty/util/Callback.html" title="interface in org.eclipse.jetty.util"><code>Callback</code></a> instance</dd>
</dl>
</li>
</ul>
<a name="onClose--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>onClose</h4>
<pre>public&nbsp;void&nbsp;onClose()</pre>
</li>
</ul>
<a name="isInProgress--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isInProgress</h4>
<pre>public&nbsp;boolean&nbsp;isInProgress()</pre>
</li>
</ul>
<a name="toString--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>public&nbsp;java.lang.String&nbsp;toString()</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
<a name="toStateString--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>toStateString</h4>
<pre>public&nbsp;java.lang.String&nbsp;toStateString()</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/WriteFlusher.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/eclipse/jetty/io/SelectorManager.html" title="class in org.eclipse.jetty.io"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../org/eclipse/jetty/io/WriterOutputStream.html" title="class in org.eclipse.jetty.io"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/eclipse/jetty/io/WriteFlusher.html" target="_top">Frames</a></li>
<li><a href="WriteFlusher.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 1995&#x2013;2018 <a href="http://webtide.com">Webtide</a>. All rights reserved.</small></p>
</body>
</html>