package org.kne.cloud.clock;

public class ExponentialBackoffTimeClock {

	private volatile long coolingTime=5000000000L;
	
	{
		resetCoolingTime();
	}
	public volatile long minCoolingTime=5000000000L,maxCoolingTime=300000000000L;
	public ExponentialBackoffTimeClock(long minCoolingTime, long maxCoolingTime) {
		super();
		this.minCoolingTime = minCoolingTime;
		this.maxCoolingTime = maxCoolingTime;
	}
	public ExponentialBackoffTimeClock() {
		super();
	}
	public long getCoolingTime() {
		return coolingTime;
	}
	public void incCoolingTime() {
		coolingTime<<=1;
		if(coolingTime>maxCoolingTime) {
			coolingTime=maxCoolingTime;
		}
	}
	public void resetCoolingTime() {
		coolingTime=minCoolingTime;
	}
}
