Alachisoft.NCache.Common.Threading.QueuedEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
package Alachisoft.NCache.Common.Threading;
import java.util.Calendar;
// the object in the Q
public class QueuedEvent {
public TimeScheduler.Task Task;
/**
* stopwatch to calculate the elapsed time for an event.
*/
public long stopwatch;
public QueuedEvent(TimeScheduler.Task task) {
this.Task = task;
stopwatch = System.currentTimeMillis();
}
public final java.util.Date getSchedTime() {
Calendar cal = Calendar.getInstance();
long milli = getInterval() - getElapsedTime();
cal.add(Calendar.MILLISECOND, (int) milli);
return cal.getTime();
}
public final long getInterval() {
return Task.GetNextInterval();
}
public final long getElapsedTime() {
//return stopwatch.ElapsedMilliseconds;
return System.currentTimeMillis() - stopwatch;
}
public boolean ReQueue() {
stopwatch = System.currentTimeMillis();
return !Task.IsCancelled();
}
}