Package jersey.repackaged.jsr166e

Examples of jersey.repackaged.jsr166e.StampedLock


        }
        return ret;
    }

    public void clear() {
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            int n = count;
            Object[] items = array;
            if (items != null) {
                for (int i = 0; i < n; i++)
                    items[i] = null;
            }
            count = 0;
        } finally {
            lock.unlockWrite(stamp);
        }
    }
View Full Code Here


        return indexOf(o, 0) >= 0;
    }

    public boolean containsAll(Collection<?> c) {
        boolean ret;
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            ret = internalContainsAll(c, 0, -1);
        } finally {
            lock.unlockRead(stamp);
        }
        return ret;
    }
View Full Code Here

    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof List))
            return false;
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            return internalEquals((List<?>)o, 0, -1);
        } finally {
            lock.unlockRead(stamp);
        }
    }
View Full Code Here

            lock.unlockRead(stamp);
        }
    }

    public E get(int index) {
        final StampedLock lock = this.lock;
        long stamp = lock.tryOptimisticRead();
        Object[] items;
        if (index >= 0 && (items = array) != null &&
            index < count && index < items.length) {
            @SuppressWarnings("unchecked") E e = (E)items[index];
            if (lock.validate(stamp))
                return e;
        }
        return lockedGet(index);
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked") private E lockedGet(int index) {
        boolean oobe = false;
        E e = null;
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            Object[] items;
            if ((items = array) != null && index < items.length &&
                index < count && index >= 0)
                e = (E)items[index];
            else
                oobe = true;
        } finally {
            lock.unlockRead(stamp);
        }
        if (oobe)
            throw new ArrayIndexOutOfBoundsException(index);
        return e;
    }
View Full Code Here

        return e;
    }

    public int hashCode() {
        int h;
        final StampedLock lock = this.lock;
        long s = lock.readLock();
        try {
            h = internalHashCode(0, -1);
        } finally {
            lock.unlockRead(s);
        }
        return h;
    }
View Full Code Here

        return h;
    }

    public int indexOf(Object o) {
        int idx;
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            idx = findFirstIndex(array, o, 0, count);
        } finally {
            lock.unlockRead(stamp);
        }
        return idx;
    }
View Full Code Here

        }
        return idx;
    }

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

        return new Itr<E>(this, 0);
    }

    public int lastIndexOf(Object o) {
        int idx;
        final StampedLock lock = this.lock;
        long stamp = lock.readLock();
        try {
            idx = findLastIndex(array, o, count - 1, 0);
        } finally {
            lock.unlockRead(stamp);
        }
        return idx;
    }
View Full Code Here

    }

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

TOP

Related Classes of jersey.repackaged.jsr166e.StampedLock

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.