Parcourir la source

make systemTimeOffset an AtomicLong

tags/2.0.1
Jonathan Cobb il y a 4 ans
Parent
révision
36e774ade1
2 fichiers modifiés avec 4 ajouts et 3 suppressions
  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 Voir le fichier

@@ -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 Voir le fichier

@@ -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


Chargement…
Annuler
Enregistrer