Class AsyncInputStream.InboundBuffer
java.lang.Object
org.jboss.resteasy.reactive.client.handlers.AsyncInputStream.InboundBuffer
- Enclosing class:
AsyncInputStream
-
Constructor Summary
ConstructorsConstructorDescriptionInboundBuffer
(io.vertx.core.Context context) InboundBuffer
(io.vertx.core.Context context, long highWaterMark) -
Method Summary
Modifier and TypeMethodDescriptionclear()
Clear the buffer synchronously.drainHandler
(io.vertx.core.Handler<Void> handler) Set anhandler
to be called when the buffer is drained and the producer can resume writing to the buffer.exceptionHandler
(io.vertx.core.Handler<Throwable> handler) Set anhandler
to be called when an exception is thrown by an handler.boolean
fetch
(long amount) Request a specificamount
of elements to be fetched, the amount is added to the actual demand.handler
(io.vertx.core.Handler<io.vertx.core.buffer.Buffer> handler) Set anhandler
to be called with elements available from this buffer.boolean
isEmpty()
void
pause()
Pause the buffer, it sets the buffer infetch
mode and clears the actual demand.void
resume()
Resume the buffer, and sets the buffer inflowing
mode.int
size()
boolean
write
(io.vertx.core.buffer.Buffer element) Write anelement
to the buffer.
-
Constructor Details
-
InboundBuffer
public InboundBuffer(io.vertx.core.Context context) -
InboundBuffer
public InboundBuffer(io.vertx.core.Context context, long highWaterMark)
-
-
Method Details
-
write
public boolean write(io.vertx.core.buffer.Buffer element) Write anelement
to the buffer. The element will be delivered synchronously to the handler when it is possible, otherwise it will be queued for later delivery.- Parameters:
element
- the element to add- Returns:
false
when the producer should stop writing
-
fetch
public boolean fetch(long amount) Request a specificamount
of elements to be fetched, the amount is added to the actual demand.Pending elements in the buffer will be delivered asynchronously on the context to the handler.
This method can be called from any thread.
- Returns:
true
when the buffer will be drained
-
clear
Clear the buffer synchronously.No handler will be called.
- Returns:
- a reference to this, so the API can be used fluently
-
pause
public void pause()Pause the buffer, it sets the buffer infetch
mode and clears the actual demand. -
resume
public void resume()Resume the buffer, and sets the buffer inflowing
mode.Pending elements in the buffer will be delivered asynchronously on the context to the handler.
This method can be called from any thread.
-
handler
public AsyncInputStream.InboundBuffer handler(io.vertx.core.Handler<io.vertx.core.buffer.Buffer> handler) Set anhandler
to be called with elements available from this buffer.- Parameters:
handler
- the handler- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
Set anhandler
to be called when the buffer is drained and the producer can resume writing to the buffer.- Parameters:
handler
- the handler to be called- Returns:
- a reference to this, so the API can be used fluently
-
exceptionHandler
Set anhandler
to be called when an exception is thrown by an handler.- Parameters:
handler
- the handler- Returns:
- a reference to this, so the API can be used fluently
-
isEmpty
public boolean isEmpty()- Returns:
- whether the buffer is empty
-
size
public int size()- Returns:
- the actual number of elements in the buffer
-