
be.bagofwords.util.OccasionalAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bow-utils Show documentation
Show all versions of bow-utils Show documentation
Utility classes that are used in the count-db project and other bow-* projects
package be.bagofwords.util;
public abstract class OccasionalAction {
private final long interval;
private long previous;
private long start;
public OccasionalAction(long interval) {
this.interval = interval;
previous = System.currentTimeMillis();
start = -1;
}
public void doOccasionalAction(T curr) {
long timeNow = System.currentTimeMillis();
if (start == -1) {
start = timeNow;
}
if (timeNow - previous > interval) {
previous = timeNow;
doAction(curr);
}
}
public long getStart() {
return start;
}
protected abstract void doAction(T curr);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy