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

io.github.jartool.console.queue.ConcurrentEvictingQueue Maven / Gradle / Ivy

The newest version!
package io.github.jartool.console.queue;

import com.google.common.collect.EvictingQueue;
import com.google.common.collect.Queues;

import java.util.Queue;

/**
 * 并发驱逐队列
 *
 * @author jartool
 */
public class ConcurrentEvictingQueue {

    /**
     * queue
     */
    private Queue queue;

    public ConcurrentEvictingQueue(int maxSize) {
        this.queue = Queues.synchronizedQueue(EvictingQueue.create(maxSize));
    }

    /**
     * push
     * @param t t
     * @return boolean
     */
    public boolean push(T t) {
        return this.queue.offer(t);
    }

    /**
     * poll
     * @return boolean
     */
    public T poll() {
        return this.queue.poll();
    }

    /**
     * isEmpty
     * @return boolean
     */
    public boolean isEmpty() {
        return this.queue.isEmpty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy