Package jersey.repackaged.jsr166e

Examples of jersey.repackaged.jsr166e.StampedLock


        if (initialCapacity < 0)
            throw new IllegalArgumentException("Illegal Capacity: "+
                                               initialCapacity);
        this.array = new Object[initialCapacity];
        this.capacityIncrement = capacityIncrement;
        this.lock = new StampedLock();
    }
View Full Code Here


    /**
     * Creates an empty vector.
     */
    public ReadMostlyVector() {
        this.capacityIncrement = 0;
        this.lock = new StampedLock();
    }
View Full Code Here

        if (elements.getClass() != Object[].class)
            elements = Arrays.copyOf(elements, elements.length, Object[].class);
        this.array = elements;
        this.count = elements.length;
        this.capacityIncrement = 0;
        this.lock = new StampedLock();
    }
View Full Code Here

    // internal constructor for clone
    ReadMostlyVector(Object[] array, int count, int capacityIncrement) {
        this.array = array;
        this.count = count;
        this.capacityIncrement = capacityIncrement;
        this.lock = new StampedLock();
    }
View Full Code Here

     * is left negative if the bound should be determined via count
     * field under lock.
     */
    final boolean lockedRemoveAll(Collection<?> c, int origin, int bound) {
        boolean removed = false;
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            int n = count;
            int fence = bound < 0 || bound > n ? n : bound;
            if (origin >= 0 && origin < fence) {
                for (Object x : c) {
                    while (rawRemoveAt(findFirstIndex(array, x, origin, fence)))
                        removed = true;
                }
            }
        } finally {
            lock.unlockWrite(stamp);
        }
        return removed;
    }
View Full Code Here

        }
        return removed;
    }

    final boolean lockedRetainAll(Collection<?> c, int origin, int bound) {
        final StampedLock lock = this.lock;
        boolean removed = false;
        if (c != this) {
            long stamp = lock.writeLock();
            try {
                Object[] items;
                int i, n;
                if ((items = array) != null && (n = count) > 0 &&
                    n < items.length && (i = origin) >= 0) {
                    int fence = bound < 0 || bound > n ? n : bound;
                    while (i < fence) {
                        if (c.contains(items[i]))
                            ++i;
                        else {
                            --fence;
                            int mv = --n - i;
                            if (mv > 0)
                                System.arraycopy(items, i + 1, items, i, mv);
                        }
                    }
                    if (count != n) {
                        count = n;
                        removed = true;
                    }
                }
            } finally {
                lock.unlockWrite(stamp);
            }
        }
        return removed;
    }
View Full Code Here

    }

    // public List methods

    public boolean add(E e) {
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            rawAdd(e);
        } finally {
            lock.unlockWrite(stamp);
        }
        return true;
    }
View Full Code Here

        }
        return true;
    }

    public void add(int index, E element) {
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            rawAddAt(index, element);
        } finally {
            lock.unlockWrite(stamp);
        }
    }
View Full Code Here

    public boolean addAll(Collection<? extends E> c) {
        Object[] elements = c.toArray();
        int len = elements.length;
        if (len == 0)
            return false;
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            Object[] items = array;
            int n = count;
            int newCount = n + len;
            if (items == null || newCount >= items.length)
                items = grow(newCount);
            System.arraycopy(elements, 0, items, n, len);
            count = newCount;
        } finally {
            lock.unlockWrite(stamp);
        }
        return true;
    }
View Full Code Here

    }

    public boolean addAll(int index, Collection<? extends E> c) {
        Object[] elements = c.toArray();
        boolean ret;
        final StampedLock lock = this.lock;
        long stamp = lock.writeLock();
        try {
            ret = rawAddAllAt(index, elements);
        } finally {
            lock.unlockWrite(stamp);
        }
        return ret;
    }
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.