public class FastContentOutputStream extends AbstractContentOutputStream implements com.google.common.util.concurrent.ListenableFuture<Boolean>
This class extends the AbstractContentOutputStream
, and forwards all write() and close() calls to a FastContentWriter
. This means that once AbstractContentOutputStream.close()
has been called, the asynchronous completion of all pending
operations can be awaited using the ListenableFuture interface of this class. Any asynchronous failure will be
rethrown when calling either of the get() methods on this class.
Please notice that the Future implementation of this class will NEVER complete unless AbstractContentOutputStream.close()
has been
called.
Modifier and Type | Field and Description |
---|---|
private FastContentWriter |
out |
BUFFERSIZE
Constructor and Description |
---|
FastContentOutputStream(ContentChannel out)
Constructs a new FastContentOutputStream that writes into the given
ContentChannel . |
FastContentOutputStream(FastContentWriter out)
Constructs a new FastContentOutputStream that writes into the given
FastContentWriter . |
Modifier and Type | Method and Description |
---|---|
void |
addListener(Runnable listener,
Executor executor) |
boolean |
cancel(boolean mayInterruptIfRunning) |
protected void |
doClose() |
protected void |
doFlush(ByteBuffer buf) |
Boolean |
get() |
Boolean |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
private final FastContentWriter out
public FastContentOutputStream(ContentChannel out)
Constructs a new FastContentOutputStream that writes into the given ContentChannel
.
out
- The ContentChannel to write the stream into.public FastContentOutputStream(FastContentWriter out)
Constructs a new FastContentOutputStream that writes into the given FastContentWriter
.
out
- The ContentWriter to write the stream into.protected void doFlush(ByteBuffer buf)
doFlush
in class AbstractContentOutputStream
protected void doClose()
doClose
in class AbstractContentOutputStream
public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<Boolean>
public Boolean get() throws InterruptedException, ExecutionException
get
in interface Future<Boolean>
InterruptedException
ExecutionException
public Boolean get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<Boolean>
InterruptedException
ExecutionException
TimeoutException
Copyright © 2017. All rights reserved.