org.xnio.conduits.Conduit
, org.xnio.conduits.SinkConduit
, org.xnio.conduits.StreamSinkConduit
public class RateLimitingStreamSinkConduit
extends org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
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.
Constructor | Description |
---|---|
RateLimitingStreamSinkConduit(org.xnio.conduits.StreamSinkConduit next,
int bytes,
long time,
java.util.concurrent.TimeUnit timeUnit) |
Modifier and Type | Method | Description |
---|---|---|
void |
awaitWritable() |
|
void |
awaitWritable(long time,
java.util.concurrent.TimeUnit timeUnit) |
|
boolean |
isWriteResumed() |
|
void |
resumeWrites() |
|
void |
suspendWrites() |
|
long |
transferFrom(java.nio.channels.FileChannel src,
long position,
long count) |
|
long |
transferFrom(org.xnio.channels.StreamSourceChannel source,
long count,
java.nio.ByteBuffer throughBuffer) |
|
void |
wakeupWrites() |
|
int |
write(java.nio.ByteBuffer src) |
|
long |
write(java.nio.ByteBuffer[] srcs,
int offs,
int len) |
|
int |
writeFinal(java.nio.ByteBuffer src) |
|
long |
writeFinal(java.nio.ByteBuffer[] srcs,
int offs,
int len) |
flush, getWriteThread, isWriteShutdown, setWriteReadyHandler, terminateWrites, truncateWrites
public RateLimitingStreamSinkConduit(org.xnio.conduits.StreamSinkConduit next, int bytes, long time, java.util.concurrent.TimeUnit timeUnit)
next
- The next conduitbytes
- The number of bytes that are allowed per time frametime
- The time frametimeUnit
- The time unitpublic int write(java.nio.ByteBuffer src) throws java.io.IOException
write
in interface org.xnio.conduits.StreamSinkConduit
write
in class org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
java.io.IOException
public long transferFrom(java.nio.channels.FileChannel src, long position, long count) throws java.io.IOException
transferFrom
in interface org.xnio.conduits.StreamSinkConduit
transferFrom
in class org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
java.io.IOException
public long transferFrom(org.xnio.channels.StreamSourceChannel source, long count, java.nio.ByteBuffer throughBuffer) throws java.io.IOException
transferFrom
in interface org.xnio.conduits.StreamSinkConduit
transferFrom
in class org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
java.io.IOException
public long write(java.nio.ByteBuffer[] srcs, int offs, int len) throws java.io.IOException
write
in interface org.xnio.conduits.StreamSinkConduit
write
in class org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
java.io.IOException
public int writeFinal(java.nio.ByteBuffer src) throws java.io.IOException
writeFinal
in interface org.xnio.conduits.StreamSinkConduit
writeFinal
in class org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
java.io.IOException
public long writeFinal(java.nio.ByteBuffer[] srcs, int offs, int len) throws java.io.IOException
writeFinal
in interface org.xnio.conduits.StreamSinkConduit
writeFinal
in class org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
java.io.IOException
public void resumeWrites()
resumeWrites
in interface org.xnio.conduits.SinkConduit
resumeWrites
in class org.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
public void suspendWrites()
suspendWrites
in interface org.xnio.conduits.SinkConduit
suspendWrites
in class org.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
public void wakeupWrites()
wakeupWrites
in interface org.xnio.conduits.SinkConduit
wakeupWrites
in class org.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
public boolean isWriteResumed()
isWriteResumed
in interface org.xnio.conduits.SinkConduit
isWriteResumed
in class org.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
public void awaitWritable() throws java.io.IOException
awaitWritable
in interface org.xnio.conduits.SinkConduit
awaitWritable
in class org.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
java.io.IOException
public void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOException
awaitWritable
in interface org.xnio.conduits.SinkConduit
awaitWritable
in class org.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
java.io.IOException
Copyright © 2018. All rights reserved.