A Content. backed by one or more ByteBuffers.
The buffers passed in the constructor are made available as Content.s
via read(). Any calls to demand(Runnable) are immediately satisfied.
| Modifier and Type | Field and Description |
|---|---|
| private final Collection | |
| private Runnable | |
| private final SerializedInvoker | |
| private Iterator | |
| private final long | |
| private final AutoLock | |
| private Content. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | demand(Runnable
the demand callback to invoke where there is a content chunk available demandCallback)Implements org. Demands to invoke the given demand callback parameter when a chunk of content is available. |
| public void | fail(Throwable
the cause of the failure failure)Implements org. Fails this content source with a |
| public Collection | |
| public long | |
| private void | |
| public Content. | |
| public boolean | rewind()
Overrides default org. Rewinds this content, if possible, so that subsequent reads return chunks starting from the beginning of this content. |
| private void |
| byteBuffers | back to summary |
|---|---|
| private final Collection<ByteBuffer> byteBuffers | |
| demandCallback | back to summary |
|---|---|
| private Runnable demandCallback | |
| invoker | back to summary |
|---|---|
| private final SerializedInvoker invoker | |
| iterator | back to summary |
|---|---|
| private Iterator<ByteBuffer> iterator | |
| length | back to summary |
|---|---|
| private final long length | |
| lock | back to summary |
|---|---|
| private final AutoLock lock | |
| terminated | back to summary |
|---|---|
| private Content. | |
| ByteBufferContentSource | back to summary |
|---|---|
| public ByteBufferContentSource(ByteBuffer... byteBuffers) | |
| ByteBufferContentSource | back to summary |
|---|---|
| public ByteBufferContentSource(Collection<ByteBuffer> byteBuffers) | |
| demand | back to summary |
|---|---|
| public void demand(Runnable demandCallback) Implements org. Doc from org. Demands to invoke the given demand callback parameter when a chunk of content is available. See how to use this method idiomatically. Implementations guarantee that calls to this method are safely reentrant so that
stack overflows are avoided in the case of mutual recursion between the execution of
the The demand callback may be invoked spuriously: a subsequent call to Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked. Calling this method when there is already a pending demand results in an
If the invocation of the demand callback throws an exception, then | |
| fail | back to summary |
|---|---|
| public void fail(Throwable failure) Implements org. Doc from org. Fails this content source with a The failure may be notified to the content reader at a later time, when
the content reader reads a content chunk, via a If Typical failure: the content being aborted by user code, or idle timeouts. If this method has already been called, then it is a no operation. | |
| getByteBuffers | back to summary |
|---|---|
| public Collection | |
| getLength | back to summary |
|---|---|
| public long getLength() Overrides default org.
| |
| invokeDemandCallback | back to summary |
|---|---|
| private void invokeDemandCallback() | |
| read | back to summary |
|---|---|
| public Content. Implements org. Doc from org. Reads a chunk of content. See how to use this method idiomatically. The returned chunk could be:
Once a read returns an Once a read returns a The content reader code must ultimately arrange for a call to
Additionally, prior to the ultimate call to Concurrent reads from different threads are not recommended, as they are inherently in a race condition. Reads performed outside the invocation context of a
| |
| rewind | back to summary |
|---|---|
| public boolean rewind() Overrides default org. Doc from org. Rewinds this content, if possible, so that subsequent reads return chunks starting from the beginning of this content.
| |
| runDemandCallback | back to summary |
|---|---|
| private void runDemandCallback(Runnable demandCallback) | |