/** * Take care of int overflow */ public static int current_time_secs() { return (int) (Time.currentTimeMillis() / 1000); }
public static int currentTimeSecs() { return (int) (currentTimeMillis() / 1000); }
private long now() { return Time.currentTimeMillis(); }
public static int current_time_secs() { return (int) (Time.currentTimeMillis() / 1000); }
public static boolean isThreadWaiting(Thread t) { if (!simulating.get()) throw new IllegalStateException("Must be in simulation mode"); AtomicLong time; synchronized (sleepTimesLock) { time = threadSleepTimes.get(t); } return !t.isAlive() || time != null && currentTimeMillis() < time.longValue(); } }
public static boolean isThreadWaiting(Thread t) { if(!simulating.get()) throw new IllegalStateException("Must be in simulation mode"); AtomicLong time; synchronized(sleepTimesLock) { time = threadSleepTimes.get(t); } return !t.isAlive() || time!=null && currentTimeMillis() < time.longValue(); } }
public static void sleep(long ms) throws InterruptedException { sleepUntil(currentTimeMillis() + ms); }
public static void sleepUntil(long targetTimeMs) throws InterruptedException { if (simulating.get()) { try { synchronized (sleepTimesLock) { threadSleepTimes.put(Thread.currentThread(), new AtomicLong(targetTimeMs)); } while (simulatedCurrTimeMs.get() < targetTimeMs) { Thread.sleep(10); } } finally { synchronized (sleepTimesLock) { if (simulating.get()) { threadSleepTimes.remove(Thread.currentThread()); } } } } else { long sleepTime = targetTimeMs - currentTimeMillis(); if (sleepTime > 0) Thread.sleep(sleepTime); } }
public static void sleep(long ms) throws InterruptedException { sleepUntil(currentTimeMillis()+ms); }
public static void sleepUntil(long targetTimeMs) throws InterruptedException { if(simulating.get()) { try { synchronized(sleepTimesLock) { threadSleepTimes.put(Thread.currentThread(), new AtomicLong(targetTimeMs)); } while(simulatedCurrTimeMs.get() < targetTimeMs) { Thread.sleep(10); } } finally { synchronized(sleepTimesLock) { threadSleepTimes.remove(Thread.currentThread()); } } } else { long sleepTime = targetTimeMs-currentTimeMillis(); if(sleepTime>0) Thread.sleep(sleepTime); } }
public String createVersion() throws IOException { Long mostRecent = mostRecentVersion(); long version = Time.currentTimeMillis(); if (mostRecent != null && version <= mostRecent) { version = mostRecent + 1; } return createVersion(version); }
public String createVersion() throws IOException { Long mostRecent = mostRecentVersion(); long version = Time.currentTimeMillis(); if(mostRecent!=null && version <= mostRecent) { version = mostRecent + 1; } return createVersion(version); }
/** * Take care of int overflow */ public static int current_time_secs() { return (int) (Time.currentTimeMillis() / 1000); }
private long now() { return Time.currentTimeMillis(); }
public static boolean isThreadWaiting(Thread t) { if (!simulating.get()) throw new IllegalStateException("Must be in simulation mode"); AtomicLong time; synchronized (sleepTimesLock) { time = threadSleepTimes.get(t); } return !t.isAlive() || time != null && currentTimeMillis() < time.longValue(); } }
public static boolean isThreadWaiting(Thread t) { if(!simulating.get()) throw new IllegalStateException("Must be in simulation mode"); AtomicLong time; synchronized(sleepTimesLock) { time = threadSleepTimes.get(t); } return !t.isAlive() || time!=null && currentTimeMillis() < time.longValue(); } }
public static void sleep(long ms) throws InterruptedException { sleepUntil(currentTimeMillis()+ms); }
public static void sleep(long ms) throws InterruptedException { sleepUntil(currentTimeMillis() + ms); }
public String createVersion() throws IOException { Long mostRecent = mostRecentVersion(); long version = Time.currentTimeMillis(); if(mostRecent!=null && version <= mostRecent) { version = mostRecent + 1; } return createVersion(version); }
public String createVersion() throws IOException { Long mostRecent = mostRecentVersion(); long version = Time.currentTimeMillis(); if (mostRecent != null && version <= mostRecent) { version = mostRecent + 1; } return createVersion(version); }