< prev index next >
src/java.httpclient/share/classes/java/net/http/AsyncConnection.java
Print this page
rev 15335 : Async Queues
@@ -23,10 +23,11 @@
* questions.
*/
package java.net.http;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.function.Consumer;
/**
* Implemented by classes that offer an asynchronous interface.
@@ -65,6 +66,30 @@
/**
* Does whatever is required to start reading. Usually registers
* an event with the selector thread.
*/
void startReading();
+
+ /**
+ * in async mode put buffers into end of send queue. Should be followed by subsequent flushAsync invocation.
+ * That allows multiple threads to put buffers into queue while some thread is writing.
+ */
+ void writeAsync(ByteBuffer[] buffers) throws IOException;
+
+ /**
+ * in async mode may put buffers into beginning of send queue, that break packet sequence and write buffers before
+ * other buffers in queue.
+ * Should be followed by subsequent flushAsync invocation.
+ * That allows multiple threads to put buffers into queue while some thread is writing.
+ */
+ void writeAsyncUnordered(ByteBuffer[] buffers) throws IOException;
+
+
+ /**
+ * should be called after any writeAsync/writeAsyncUnordered invocation.
+ * If there is a race to flushAsync from several threads one thread (race winner) capture flush operation and write the whole
+ * queue content. Other threads (race losers) exits from the method (not blocking) and continue execution.
+ */
+ void flushAsync();
+
+
}
< prev index next >