public static void main(String[] args) throws Exception { DefaultProgressTracker<Long> tracker = new DefaultProgressTracker<>(new ProgressCallback<Long>() { @Override public long getProgressPulsePct() { trackVolume(totalVolume, tracker); trackFlow(totalVolume, tracker);
private static void trackVolume(final long totalVolume, DefaultProgressTracker<Long> tracker) throws InterruptedException { System.out.println(); System.out.println("total volume " + tracker.totalVolume); System.out.println("actual pulse " + tracker.pulsePct); System.out.println("pulse volume " + tracker.pulseAtVolume); System.out.println("min pulse ms " + tracker.minPulseInterval/1000000); System.out.println(); //for(int i = 0; i < totalVolume; ++i) { // tracker.progressed(); //} tracker.starting(totalVolume); int i = 0; while(true) { tracker.processing((long)i); tracker.processed((long)i); if(++i >= totalVolume) { break; } Thread.currentThread().sleep(500 - i*10); } tracker.complete(); }
public void setProgressCallback(String id, ProgressCallback<?> callback) { if (callback == null) { progressTrackers.remove(id); } else { progressTrackers.put(id, new DefaultProgressTracker<>(callback)); } }
public DefaultProgressTracker(ProgressCallback<T> callback) { this.callback = callback; this.pulsePct = callback.getProgressPulsePct(); if(pulsePct > 100) { throw new IllegalArgumentException("The argument was not expected to be bigger than 100 but was " + pulsePct); } setMinPulseMs(callback.getMinPulseIntervalMs()); setMaxPulseMs(callback.getMaxPulseIntervalMs()); }
private static void trackFlow(final long totalVolume, DefaultProgressTracker<Long> tracker) throws InterruptedException { System.out.println(); System.out.println("total volume " + tracker.totalVolume); System.out.println("actual pulse " + tracker.pulsePct); System.out.println("pulse volume " + tracker.pulseAtVolume); System.out.println("min pulse ms " + tracker.minPulseInterval/1000000); System.out.println(""); //for(int i = 0; i < totalVolume; ++i) { // tracker.progressed(); //} tracker.starting(totalVolume); int i = 0; while(true) { tracker.processing((long)i); tracker.processed((long)i); if(++i >= totalVolume) { break; } Thread.currentThread().sleep(500 - i*10); } tracker.complete(); } }
@SuppressWarnings("unchecked") public static <T> ProgressTracker<T> getNoOpProgressTracker() { return (ProgressTracker<T>) (NO_OP_PROGRESS_TRACKER == null ? NO_OP_PROGRESS_TRACKER = new DefaultProgressTracker<>(new NoOpProgressCallback<>()) : NO_OP_PROGRESS_TRACKER); }
public static ProgressTracker<FPID> newFindTracker(PmCommandInvocation invoc) { FindTracker findTracker = new FindTracker(invoc.getPmSession()); findTracker.commandStart(invoc); ProgressTracker<FPID> tracker = new DefaultProgressTracker<>(findTracker); return tracker; } }