Examples of StampedLock


Examples of jersey.repackaged.jsr166e.StampedLock

            throw new ArrayIndexOutOfBoundsException(index);
        return oldValue;
    }

    public boolean remove(Object o) {
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            return rawRemoveAt(findFirstIndex(array, o, 0, count));
        } finally {
            lock.unlockWrite(stamp);
        }
    }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

    }

    @SuppressWarnings("unchecked") public E set(int index, E element) {
        E oldValue = null;
        boolean oobe = false;
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            Object[] items = array;
            if (items == null || index < 0 || index >= count)
                oobe = true;
            else {
                oldValue = (E) items[index];
                items[index] = element;
            }
        } finally {
            lock.unlockWrite(stamp);
        }
        if (oobe)
            throw new ArrayIndexOutOfBoundsException(index);
        return oldValue;
    }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

            throw new ArrayIndexOutOfBoundsException(index);
        return oldValue;
    }

    public int size() {
        final StampedLock lock = this.lock;
        long stamp = lock.tryOptimisticRead();
        return count; // no need for validation
    }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

        return count; // no need for validation
    }

    private int lockedSize() {
        int n;
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            n = count;
        } finally {
            lock.unlockRead(stamp);
        }
        return n;
    }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

    public List<E> subList(int fromIndex, int toIndex) {
        int ssize = toIndex - fromIndex;
        if (ssize >= 0 && fromIndex >= 0) {
            ReadMostlyVectorSublist<E> ret = null;
            final StampedLock lock = this.lock;
            long stamp = lock.readLock();
            try {
                if (toIndex <= count)
                    ret = new ReadMostlyVectorSublist<E>(this, fromIndex, ssize);
            } finally {
                lock.unlockRead(stamp);
            }
            if (ret != null)
                return ret;
        }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

        throw new ArrayIndexOutOfBoundsException(fromIndex < 0 ? fromIndex : toIndex);
    }

    public Object[] toArray() {
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            return internalToArray(0, -1);
        } finally {
            lock.unlockRead(stamp);
        }
    }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

            lock.unlockRead(stamp);
        }
    }

    public <T> T[] toArray(T[] a) {
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            return internalToArray(a, 0, -1);
        } finally {
            lock.unlockRead(stamp);
        }
    }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

            lock.unlockRead(stamp);
        }
    }

    public String toString() {
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            return internalToString(0, -1);
        } finally {
            lock.unlockRead(stamp);
        }
    }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

     * @param e element to be added to this list, if absent
     * @return {@code true} if the element was added
     */
    public boolean addIfAbsent(E e) {
        boolean ret;
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            if (findFirstIndex(array, e, 0, count) < 0) {
                rawAdd(e);
                ret = true;
            }
            else
                ret = false;
        } finally {
            lock.unlockWrite(stamp);
        }
        return ret;
    }
View Full Code Here

Examples of jersey.repackaged.jsr166e.StampedLock

    /** Interface describing a void action of one argument */
    public interface Action<A> { void apply(A a); }

    public void forEachReadOnly(Action<E> action) {
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            Object[] items;
            int len, n;
            if ((items = array) != null && (len = items.length) > 0 &&
                (n = count) <= len) {
                for (int i = 0; i < n; ++i) {
                    @SuppressWarnings("unchecked") E e = (E)items[i];
                    action.apply(e);
                }
            }
        } finally {
            lock.unlockRead(stamp);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.