C# Class Universe.ClientStack.TokenBucket

A hierarchical token bucket for bandwidth throttling. See http://en.wikipedia.org/wiki/Token_bucket for more information
显示文件 Open project: Virtual-Universe/Virtual-Universe Class Usage Examples

Public Methods

Method Description
Drip ( ) : bool

Add tokens to the bucket over time. The number of tokens added each call depends on the length of time that has passed since the last call to Drip

RemoveTokens ( int amount ) : bool

Remove a given number of tokens from the bucket

RemoveTokens ( int amount, bool &dripSucceeded ) : bool

Remove a given number of tokens from the bucket

TokenBucket ( TokenBucket parent, int maxBurst, int dripRate ) : System

Default constructor

Method Details

Drip() public method

Add tokens to the bucket over time. The number of tokens added each call depends on the length of time that has passed since the last call to Drip
public Drip ( ) : bool
return bool

RemoveTokens() public method

Remove a given number of tokens from the bucket
public RemoveTokens ( int amount ) : bool
amount int Number of tokens to remove from the bucket
return bool

RemoveTokens() public method

Remove a given number of tokens from the bucket
public RemoveTokens ( int amount, bool &dripSucceeded ) : bool
amount int Number of tokens to remove from the bucket
dripSucceeded bool /// True if tokens were added to the bucket /// during this call, otherwise false ///
return bool

TokenBucket() public method

Default constructor
public TokenBucket ( TokenBucket parent, int maxBurst, int dripRate ) : System
parent TokenBucket /// Parent bucket if this is a child bucket, or /// null if this is a root bucket ///
maxBurst int /// Maximum size of the bucket in bytes, or /// zero if this bucket has no maximum capacity ///
dripRate int /// Rate that the bucket fills, in bytes per /// second. If zero, the bucket always remains full ///
return System