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

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

package Alachisoft.NCache.Common.Threading;

import Alachisoft.NCache.Common.DataStructures.BinaryPriorityQueue;

/**
 * The Q
 */
public class EventQueue extends BinaryPriorityQueue {

    public EventQueue() {
        super(new EventQueueComparer());
    }

    /**
     * Checks if the list is empty
     *
     * @return
     */
    public final boolean getIsEmpty() {
        synchronized (this) {
            return (getCount() == 0);
        }
    }

    public final QueuedEvent Pop() {
        synchronized (this) {
            Object tempVar = super.pop();
            return (QueuedEvent) ((tempVar instanceof QueuedEvent) ? tempVar : null);
        }
    }

    public final QueuedEvent Peek() {
        synchronized (this) {
            Object tempVar = super.peek();
            return (QueuedEvent) ((tempVar instanceof QueuedEvent) ? tempVar : null);
        }
    }

    public final int Push(Object O) {
        synchronized (this) {
            int res = super.push(O);
            //Basit: Monitor.Pulse(this); changed to this.notify
            //Monitor.Pulse(this);
            Alachisoft.NCache.Common.Threading.Monitor.pulse(this);//this.notify();
            return res;
        }
    }

    /**
     * does what it says
     */
    @Override
    public final void Clear() {
        synchronized (this) {
            super.Clear();
            //Basit: Monitor.Pulse(this); changed to this.notify
            //Monitor.Pulse(this);
            Alachisoft.NCache.Common.Threading.Monitor.pulse(this);//this.notify();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy