Sfoglia il codice sorgente

make systemTimeOffset an AtomicLong

tags/2.0.1
Jonathan Cobb 4 anni fa
parent
commit
36e774ade1
2 ha cambiato i file con 4 aggiunte e 3 eliminazioni
  1. +3
    -2
      src/main/java/org/cobbzilla/util/daemon/ZillaRuntime.java
  2. +1
    -1
      src/main/java/org/cobbzilla/util/time/CurrentTime.java

+ 3
- 2
src/main/java/org/cobbzilla/util/daemon/ZillaRuntime.java Vedi File

@@ -286,8 +286,9 @@ public class ZillaRuntime {

public static String uuid() { return UUID.randomUUID().toString(); }

@Getter @Setter private static volatile long systemTimeOffset = 0;
public static long now() { return System.currentTimeMillis() + systemTimeOffset; }
@Getter @Setter private static AtomicLong systemTimeOffset = new AtomicLong(0L);
public static long incrementSystemTimeOffset(long t) { return systemTimeOffset.addAndGet(t); }
public static long now() { return System.currentTimeMillis() + systemTimeOffset.get(); }
public static String hexnow() { return toHexString(now()); }
public static String hexnow(long now) { return toHexString(now); }
public static long realNow() { return System.currentTimeMillis(); }


+ 1
- 1
src/main/java/org/cobbzilla/util/time/CurrentTime.java Vedi File

@@ -17,7 +17,7 @@ public class CurrentTime {
public CurrentTime(DateTimeZone tz) {
zone = tz.getID();
now = new CurrentTimeValues(tz, ZillaRuntime.now());
realNow = ZillaRuntime.getSystemTimeOffset() == 0 ? null : new CurrentTimeValues(tz, ZillaRuntime.realNow());
realNow = ZillaRuntime.getSystemTimeOffset().get() == 0 ? null : new CurrentTimeValues(tz, ZillaRuntime.realNow());
}

@NoArgsConstructor


Caricamento…
Annulla
Salva