Class ByteBucketST
java.lang.Object
com.biglybt.core.networkmanager.impl.ByteBucketST
- All Implemented Interfaces:
ByteBucket
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate longprivate booleanprivate longprivate long -
Constructor Summary
ConstructorsModifierConstructorDescriptionByteBucketST(long rate_bytes_per_sec) Create a new byte-bucket with the given byte fill (guaranteed) rate.privateByteBucketST(long rate_bytes_per_sec, long burst_rate) Create a new byte-bucket with the given byte fill (guaranteed) rate and the given burst rate. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidMake sure the bucket's burst rate is at least MSS-sized, otherwise it will never allow a full packet's worth of data.longGet the number of bytes currently available for use.longGet the configured burst rate.longgetRate()Get the configured fill rate.voidsetBytesUsed(long bytes_used) Update the bucket with the number of bytes just used.voidsetFrozen(boolean f) voidsetRate(long rate_bytes_per_sec) Set the current fill/guaranteed rate, with a burst rate of 1.2X the given rate.voidsetRate(long rate_bytes_per_sec, long burst_rate) Set the current fill/guaranteed rate, along with the burst rate.private void
-
Field Details
-
rate
private long rate -
burst_rate
private long burst_rate -
avail_bytes
private long avail_bytes -
prev_update_time
private long prev_update_time -
frozen
private boolean frozen
-
-
Constructor Details
-
ByteBucketST
public ByteBucketST(long rate_bytes_per_sec) Create a new byte-bucket with the given byte fill (guaranteed) rate. Burst rate is set to default 1.2X of given fill rate.- Parameters:
rate_bytes_per_sec- fill rate
-
ByteBucketST
private ByteBucketST(long rate_bytes_per_sec, long burst_rate) Create a new byte-bucket with the given byte fill (guaranteed) rate and the given burst rate.- Parameters:
rate_bytes_per_sec- fill rateburst_rate- max rate
-
-
Method Details
-
getAvailableByteCount
public long getAvailableByteCount()Get the number of bytes currently available for use.- Specified by:
getAvailableByteCountin interfaceByteBucket- Returns:
- number of free bytes
-
setBytesUsed
public void setBytesUsed(long bytes_used) Update the bucket with the number of bytes just used.- Specified by:
setBytesUsedin interfaceByteBucket- Parameters:
bytes_used-
-
getRate
public long getRate()Get the configured fill rate.- Specified by:
getRatein interfaceByteBucket- Returns:
- guaranteed rate in bytes per sec
-
getBurstRate
public long getBurstRate()Get the configured burst rate.- Returns:
- burst rate in bytes per sec
-
setRate
public void setRate(long rate_bytes_per_sec) Set the current fill/guaranteed rate, with a burst rate of 1.2X the given rate.- Specified by:
setRatein interfaceByteBucket- Parameters:
rate_bytes_per_sec-
-
setRate
public void setRate(long rate_bytes_per_sec, long burst_rate) Set the current fill/guaranteed rate, along with the burst rate.- Parameters:
rate_bytes_per_sec-burst_rate-
-
setFrozen
public void setFrozen(boolean f) - Specified by:
setFrozenin interfaceByteBucket
-
update_avail_byte_count
private void update_avail_byte_count() -
ensureByteBucketMinBurstRate
private void ensureByteBucketMinBurstRate()Make sure the bucket's burst rate is at least MSS-sized, otherwise it will never allow a full packet's worth of data.
-