All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.Threading.QueuedEvent Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy