Allows send speed to be throttled
Note that throttling is applied after an initial write, so if a big write is performed initially it may be a while before it can write again.
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private final int | |
| private long | |
| private boolean | |
| private long | |
| private final long | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | RateLimitingStreamSinkConduit(StreamSinkConduit
The next conduit next, int The number of bytes that are allowed per time frame bytes, long The time frame time, TimeUnit The time unit timeUnit)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | awaitWritable()
Overrides org. Implements org. Block until this channel becomes writable again. |
| public void | awaitWritable(long
the time to wait time, TimeUnit the time unit timeUnit)Overrides org. Implements org. Block until this conduit becomes writable again, or until the timeout expires. |
| private boolean | |
| private void | |
| private void | |
| public boolean | isWriteResumed()
Overrides org. Implements org. Determine whether write notifications are currently enabled. |
| public void | resumeWrites()
Overrides org. Implements org. Indicate that the conduit's |
| public void | suspendWrites()
Overrides org. Implements org. Indicate that calling the conduit's |
| public long | transferFrom(FileChannel
the file to read from src, long the position within the file from which the transfer is to begin position, long the number of bytes to be transferred count)Overrides org. Implements org. Transfer bytes into this conduit from the given file. |
| public long | transferFrom(StreamSourceChannel
the source to read from source, long the number of bytes to be transferred count, ByteBuffer the buffer to copy through. throughBuffer)Overrides org. Implements org. Transfers bytes from the given channel source. |
| public void | wakeupWrites()
Overrides org. Implements org. Indicate that the conduit's |
| public int | write(ByteBuffer
the buffer containing data to write src)Overrides org. Implements org. Writes a sequence of bytes to this conduit from the given buffer. |
| public long | write(ByteBuffer[]
the buffers containing data to write srcs, int the offset into the buffer array offs, int the number of buffers to write len)Overrides org. Implements org. Writes a sequence of bytes to this conduit from the given buffers. |
| public int | writeFinal(ByteBuffer
The data to write src)Overrides org. Implements org. Writes some data to the conduit, with the same semantics as
|
| public long | writeFinal(ByteBuffer[]
The buffers from which bytes are to be retrieved srcs, int The offset within the buffer array of the first buffer from
which bytes are to be retrieved; must be non-negative and no
larger than srcs.length offs, int The maximum number of buffers to be accessed; must be
non-negative and no larger than
srcs.length - offset len)Overrides org. Implements org. Writes some data to the conduit, with the same semantics as
|
| byteCount | back to summary |
|---|---|
| private int byteCount | |
| bytes | back to summary |
|---|---|
| private final int bytes | |
| nextSendTime | back to summary |
|---|---|
| private long nextSendTime | |
| scheduled | back to summary |
|---|---|
| private boolean scheduled | |
| startTime | back to summary |
|---|---|
| private long startTime | |
| time | back to summary |
|---|---|
| private final long time | |
| writesResumed | back to summary |
|---|---|
| private boolean writesResumed | |
| RateLimitingStreamSinkConduit | back to summary |
|---|---|
public RateLimitingStreamSinkConduit(StreamSinkConduit next, int bytes, long time, TimeUnit timeUnit)
| |
| awaitWritable | back to summary |
|---|---|
| public void awaitWritable() throws IOException Overrides org. Implements org. Doc from org. Block until this channel becomes writable again. This method may return spuriously before the channel becomes writable.
| |
| awaitWritable | back to summary |
|---|---|
| public void awaitWritable(long time, TimeUnit timeUnit) throws IOException Overrides org. Implements org. Doc from org. Block until this conduit becomes writable again, or until the timeout expires. This method may return spuriously before the conduit becomes writable or the timeout expires.
| |
| canSend | back to summary |
|---|---|
| private boolean canSend() | |
| handleWritesResumedWhenBlocked | back to summary |
|---|---|
| private void handleWritesResumedWhenBlocked() | |
| handleWritten | back to summary |
|---|---|
| private void handleWritten(long written) | |
| isWriteResumed | back to summary |
|---|---|
| public boolean isWriteResumed() Overrides org. Implements org. Doc from org. Determine whether write notifications are currently enabled.
| |
| resumeWrites | back to summary |
|---|---|
| public void resumeWrites() Overrides org. Implements org. Doc from org. Indicate that the conduit's
| |
| suspendWrites | back to summary |
|---|---|
| public void suspendWrites() Overrides org. Implements org. Doc from org. Indicate that calling the conduit's
| |
| transferFrom | back to summary |
|---|---|
| public long transferFrom(FileChannel src, long position, long count) throws IOException Overrides org. Implements org. Doc from org. Transfer bytes into this conduit from the given file.
| |
| transferFrom | back to summary |
|---|---|
| public long transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException Overrides org. Implements org. Doc from org. Transfers bytes from the given channel source. On entry,
| |
| wakeupWrites | back to summary |
|---|---|
| public void wakeupWrites() Overrides org. Implements org. Doc from org. Indicate that the conduit's
| |
| write | back to summary |
|---|---|
| public int write(ByteBuffer src) throws IOException Overrides org. Implements org. Doc from org. Writes a sequence of bytes to this conduit from the given buffer.
| |
| write | back to summary |
|---|---|
| public long write(ByteBuffer[] srcs, int offs, int len) throws IOException Overrides org. Implements org. Doc from org. Writes a sequence of bytes to this conduit from the given buffers.
| |
| writeFinal | back to summary |
|---|---|
| public int writeFinal(ByteBuffer src) throws IOException Overrides org. Implements org. Doc from org. Writes some data to the conduit, with the same semantics as
| |
| writeFinal | back to summary |
|---|---|
| public long writeFinal(ByteBuffer[] srcs, int offs, int len) throws IOException Overrides org. Implements org. Doc from org. Writes some data to the conduit, with the same semantics as
| |