0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This file is available under and governed by the GNU General Public 0N/A * License version 2 only, as published by the Free Software Foundation. 0N/A * However, the following notice accompanied the original version of this 0N/A * Written by Doug Lea with assistance from members of JCP JSR-166 0N/A * Expert Group and released to the public domain, as explained at 0N/A * An {@code AtomicStampedReference} maintains an object reference 0N/A * along with an integer "stamp", that can be updated atomically. 3387N/A * <p>Implementation note: This implementation maintains stamped 0N/A * references by creating internal objects representing "boxed" 0N/A * [reference, integer] pairs. 0N/A * @param <V> The type of object referred to by this reference 0N/A * Creates a new {@code AtomicStampedReference} with the given 0N/A * @param initialRef the initial reference 0N/A * @param initialStamp the initial stamp 0N/A * Returns the current value of the reference. 0N/A * @return the current value of the reference 0N/A * Returns the current value of the stamp. 0N/A * @return the current value of the stamp 0N/A * Returns the current values of both the reference and the stamp. 0N/A * Typical usage is {@code int[1] holder; ref = v.get(holder); }. 0N/A * @param stampHolder an array of size of at least one. On return, 0N/A * {@code stampholder[0]} will hold the value of the stamp. 0N/A * @return the current value of the reference 0N/A * Atomically sets the value of both the reference and stamp 0N/A * to the given update values if the 0N/A * current reference is {@code ==} to the expected reference 0N/A * and the current stamp is equal to the expected stamp. 0N/A * and does not provide ordering guarantees, so is only rarely an 0N/A * appropriate alternative to {@code compareAndSet}. 0N/A * @param expectedReference the expected value of the reference 0N/A * @param newReference the new value for the reference 0N/A * @param expectedStamp the expected value of the stamp 0N/A * @param newStamp the new value for the stamp 0N/A * @return true if successful 0N/A * Atomically sets the value of both the reference and stamp 0N/A * to the given update values if the 0N/A * current reference is {@code ==} to the expected reference 0N/A * and the current stamp is equal to the expected stamp. 0N/A * @param expectedReference the expected value of the reference 0N/A * @param newReference the new value for the reference 0N/A * @param expectedStamp the expected value of the stamp 0N/A * @param newStamp the new value for the stamp 0N/A * @return true if successful 0N/A * Unconditionally sets the value of both the reference and stamp. 0N/A * @param newReference the new value for the reference 0N/A * @param newStamp the new value for the stamp 0N/A * Atomically sets the value of the stamp to the given update value 0N/A * if the current reference is {@code ==} to the expected 0N/A * reference. Any given invocation of this operation may fail 0N/A * (return {@code false}) spuriously, but repeated invocation 0N/A * when the current value holds the expected value and no other 0N/A * thread is also attempting to set the value will eventually 0N/A * @param expectedReference the expected value of the reference 0N/A * @param newStamp the new value for the stamp 0N/A * @return true if successful 3387N/A // Convert Exception to corresponding Error