/** * Returns an increasing unique value based on the {@code System.currentTimeMillis()} * with some additional reserved space for a counter. * * @see net.sf.ehcache.util.Timestamper#BIN_DIGITS * @return uniquely & increasing value */ public static long next() { int runs = 0; while (true) { long base = SlewClock.timeMillis() << BIN_DIGITS; long maxValue = base + ONE_MS - 1; for (long current = VALUE.get(), update = Math.max(base, current + 1); update < maxValue; current = VALUE.get(), update = Math.max(base, current + 1)) { if (VALUE.compareAndSet(current, update)) { if (runs > 1) { log(base, "Thread spin-waits on time to pass. Looped " + "{} times, you might want to increase -Dnet.sf.ehcache.util.Timestamper.shift", runs); } return update; } } ++runs; } }
/** * Returns an increasing unique value based on the {@code System.currentTimeMillis()} * with some additional reserved space for a counter. * * @see net.sf.ehcache.util.Timestamper#BIN_DIGITS * @return uniquely & increasing value */ public static long next() { int runs = 0; while (true) { long base = SlewClock.timeMillis() << BIN_DIGITS; long maxValue = base + ONE_MS - 1; for (long current = VALUE.get(), update = Math.max(base, current + 1); update < maxValue; current = VALUE.get(), update = Math.max(base, current + 1)) { if (VALUE.compareAndSet(current, update)) { if (runs > 1) { log(base, "Thread spin-waits on time to pass. Looped " + "{} times, you might want to increase -Dnet.sf.ehcache.util.Timestamper.shift", runs); } return update; } } ++runs; } }
/** * Returns an increasing unique value based on the System.currentTimeMillis() * with some additional reserved space for a counter. * * @see net.sf.ehcache.util.Timestamper#BIN_DIGITS * @return uniquely & increasing value */ public static long next() { int runs = 0; while (true) { long base = SlewClock.timeMillis() << BIN_DIGITS; long maxValue = base + ONE_MS - 1; for (long current = VALUE.get(), update = Math.max(base, current + 1); update < maxValue; current = VALUE.get(), update = Math.max(base, current + 1)) { if (VALUE.compareAndSet(current, update)) { if (runs > 1) { log(base, "Thread spin-waits on time to pass. Looped " + "{} times, you might want to increase -Dnet.sf.ehcache.util.Timestamper.shift", runs); } return update; } } ++runs; } }
/** * Returns an increasing unique value based on the System.currentTimeMillis() * with some additional reserved space for a counter. * * @see net.sf.ehcache.util.Timestamper#BIN_DIGITS * @return uniquely & increasing value */ public static long next() { int runs = 0; while (true) { long base = SlewClock.timeMillis() << BIN_DIGITS; long maxValue = base + ONE_MS - 1; for (long current = VALUE.get(), update = Math.max(base, current + 1); update < maxValue; current = VALUE.get(), update = Math.max(base, current + 1)) { if (VALUE.compareAndSet(current, update)) { if (runs > 1) { log(base, "Thread spin-waits on time to pass. Looped " + "{} times, you might want to increase -Dnet.sf.ehcache.util.Timestamper.shift", runs); } return update; } } ++runs; } }