Pārlūkot izejas kodu

make systemTimeOffset an AtomicLong

tags/2.0.1
Jonathan Cobb pirms 4 gadiem
vecāks
revīzija
36e774ade1
2 mainītis faili ar 4 papildinājumiem un 3 dzēšanām
  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 Parādīt failu

@@ -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 Parādīt failu

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


Notiek ielāde…
Atcelt
Saglabāt