FileDocCategorySizeDatePackage
Timestamper.javaAPI DocHibernate 3.2.5780Thu Jun 03 11:31:32 BST 2004org.hibernate.cache

Timestamper

public final class Timestamper extends Object
Generates increasing identifiers (in a single VM only). Not valid across multiple VMs. Identifiers are not necessarily strictly increasing, but usually are.

Fields Summary
private static short
counter
private static long
time
private static final int
BIN_DIGITS
public static final short
ONE_MS
Constructors Summary
private Timestamper()

Methods Summary
public static longnext()

	
	    
		synchronized(Timestamper.class) {
			long newTime = System.currentTimeMillis() << BIN_DIGITS;
			if (time<newTime) {
				time = newTime;
				counter = 0;
			}
			else if (counter < ONE_MS - 1 ) {
				counter++;
			}
			
			return time + counter;
		}