FileDocCategorySizeDatePackage
PausableAverage.javaAPI DocAzureus 3.0.3.42046Thu Sep 28 03:19:26 BST 2006org.gudy.azureus2.core3.util

PausableAverage

public class PausableAverage extends Average

Fields Summary
private long
offset
private long
pause_time
Constructors Summary
private PausableAverage(int _refreshRate, int _period)

		super( _refreshRate, _period );
	
Methods Summary
public voidaddValue(long value)

		
		super.addValue( value );
	
public longgetAverage()

		long	average = super.getAverage();
		
		return( average );
	
protected longgetEffectiveTime()

		return( SystemTime.getCurrentTime() - offset );
	
public static org.gudy.azureus2.core3.util.PausableAveragegetPausableInstance(int refreshRate, int period)

		if ( refreshRate < 100 ){
			
			return null;
		}
		
		if (( period * 1000 ) < refreshRate ){
			
			return null;
		}
	
		return new PausableAverage(refreshRate, period);
	
public voidpause()

		if ( pause_time == 0 ){
			
			pause_time = SystemTime.getCurrentTime();
		}
	
public voidresume()

		if ( pause_time != 0 ){
			
			long	now = SystemTime.getCurrentTime();
			
			if ( now > pause_time ){
				
				offset += now - pause_time;
			}
			
			pause_time	= 0;
		}