Package edu.emory.mathcs.backport.java.util.concurrent.locks

Examples of edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock


  /**
   * @see org.springmodules.lucene.index.factory.concurrent.ConcurrentIndexFactory#initConcurrentResources()
   */
  public void initConcurrentResources() throws Exception {
    lock = new ReentrantLock();
  }
View Full Code Here


    private final AtomicInteger getCount = new AtomicInteger();
    private final AtomicInteger hitCount = new AtomicInteger();

    public DefaultBufferPool() {
        for (int i = 0; i < POSITIVE_INTEGER_SIZE; i++) {
            directLocks[i] = new ReentrantLock();
            heapLocks[i] = new ReentrantLock();
        }
    }
View Full Code Here

            IoServiceListenerSupport serviceListeners,
            SocketAddress localAddress, IoHandler handler, VmPipe remoteEntry) {
        this.service = service;
        this.serviceConfig = serviceConfig;
        this.serviceListeners = serviceListeners;
        this.lock = new ReentrantLock();
        this.localAddress = localAddress;
        this.remoteAddress = this.serviceAddress = remoteEntry.getAddress();
        this.handler = handler;
        this.filterChain = new VmPipeFilterChain(this);
        this.pendingDataQueue = new Queue();
View Full Code Here

            IoServiceListenerSupport serviceListeners,
            SocketAddress localAddress, IoHandler handler, VmPipe remoteEntry) {
        this.service = service;
        this.serviceConfig = serviceConfig;
        this.serviceListeners = serviceListeners;
        this.lock = new ReentrantLock();
        this.localAddress = localAddress;
        this.remoteAddress = this.serviceAddress = remoteEntry.getAddress();
        this.handler = handler;
        this.filterChain = new VmPipeFilterChain(this);
        this.pendingDataQueue = new Queue();
View Full Code Here

            return -1;
        }

        public boolean remove(Object x) {
            boolean removed;
            final ReentrantLock lock = this.lock;
            lock.lock();
            try {
                int i;
                if (x instanceof ScheduledFutureTask)
                    i = ((ScheduledFutureTask)x).heapIndex;
                else
                    i = indexOf(x);
                if (removed = (i >= 0 && i < size && queue[i] == x)) {
                    setIndex(x, -1);
                    int s = --size;
                    RunnableScheduledFuture replacement = queue[s];
                    queue[s] = null;
                    if (s != i) {
                        siftDown(i, replacement);
                        if (queue[i] == replacement)
                            siftUp(i, replacement);
                    }
                }
            } finally {
                lock.unlock();
            }
            return removed;
        }
View Full Code Here

            return removed;
        }

        public int size() {
            int s;
            final ReentrantLock lock = this.lock;
            lock.lock();
            try {
                s = size;
            } finally {
                lock.unlock();
            }
            return s;
        }
View Full Code Here

        public int remainingCapacity() {
            return Integer.MAX_VALUE;
        }

        public Object peek() {
            final ReentrantLock lock = this.lock;
            lock.lock();
            try {
                return queue[0];
            } finally {
                lock.unlock();
            }
        }
View Full Code Here

        public boolean offer(Object x) {
            if (x == null)
                throw new NullPointerException();
            RunnableScheduledFuture e = (RunnableScheduledFuture)x;
            final ReentrantLock lock = this.lock;
            lock.lock();
            try {
                int i = size;
                if (i >= queue.length)
                    grow();
                size = i + 1;
                boolean notify;
                if (i == 0) {
                    notify = true;
                    queue[0] = e;
                    setIndex(e, 0);
                }
                else {
                    notify = e.compareTo(queue[0]) < 0;
                    siftUp(i, e);
                }
                if (notify)
                    available.signalAll();
            } finally {
                lock.unlock();
            }
            return true;
  }
View Full Code Here

        public boolean offer(Object e, long timeout, TimeUnit unit) {
            return offer(e);
        }
       
        public Object poll() {
            final ReentrantLock lock = this.lock;
            lock.lock();
            try {
                RunnableScheduledFuture first = queue[0];
                if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0)
                    return null;
                else
                    return finishPoll(first);
            } finally {
                lock.unlock();
            }
        }
View Full Code Here

                lock.unlock();
            }
        }

        public Object take() throws InterruptedException {
            final ReentrantLock lock = this.lock;
            lock.lockInterruptibly();
            try {
                for (;;) {
                    RunnableScheduledFuture first = queue[0];
                    if (first == null)
                        available.await();
                    else {
                        long delay =  first.getDelay(TimeUnit.NANOSECONDS);
                        if (delay > 0)
                            available.await(delay, TimeUnit.NANOSECONDS);
                        else
                            return finishPoll(first);
                    }
                }
            } finally {
                lock.unlock();
            }
        }
View Full Code Here

TOP

Related Classes of edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.