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

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

There is a newer version: 5.3.3
Show newest version
package Alachisoft.NCache.Common.Threading;

//	public class RepeatEvent : QueuedEvent
//	{
//		private int iNumberOfShots; // -1 = continuous
//
//		public RepeatEvent(long sched, int interval, int qty) : base(sched, interval, true)
//		{
//			iNumberOfShots = qty;
//		}
//
//		public override bool ReQueue()
//		{
//			base.ReQueue();
//			if (iNumberOfShots != -1)
//				iNumberOfShots--;
//			return (iNumberOfShots != 0);
//		}
//
//
//		public override string ToString()
//		{
//			if (iNumberOfShots == -1)
//				return "RepeatEvent fired at " + sched.ToString() + " (no limit)";	
//			else
//				return "RepeatEvent fired at " + sched.ToString() + " with "+(iNumberOfShots)+" shots left";	
//		}
//
//	}
//
//	public class OneShotEvent : RepeatEvent 
//	{
//		public OneShotEvent(long sched) : base(sched, 0, 1)
//		{}
//
//		public override string ToString()
//		{
//			return "OneShotEvent fired at " + sched.ToString();
//		}
//	}
//

// the comparer
//C# TO JAVA CONVERTER TODO TASK: The interface type was changed to the closest equivalent Java type, but the methods implemented will need adjustment:
public class EventQueueComparer implements java.util.Comparator {
    public final int compare(Object x, Object y) {
        QueuedEvent xx = (QueuedEvent) ((x instanceof QueuedEvent) ? x : null);
        QueuedEvent yy = (QueuedEvent) ((y instanceof QueuedEvent) ? y : null);
        return xx.getSchedTime().compareTo(yy.getSchedTime());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy