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

com.github.ltsopensource.nio.processor.WriteQueue Maven / Gradle / Ivy

package com.github.ltsopensource.nio.processor;

import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author Robert HG ([email protected]) on 1/31/16.
 */
public class WriteQueue {

    private ConcurrentLinkedQueue queue = new ConcurrentLinkedQueue();
    private volatile ReentrantLock lock = new ReentrantLock();

    public void offer(WriteRequest message) {
        queue.offer(message);
    }

    public WriteRequest peek() {
        return queue.peek();
    }

    public WriteRequest poll() {
        return queue.poll();
    }

    public boolean tryLock() {
        return lock.tryLock();
    }

    public void unlock() {
        lock.unlock();
    }

    public boolean isEmpty() {
        return queue.isEmpty();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy