author | dl |
Sat, 14 Sep 2019 11:26:26 -0700 | |
changeset 58138 | 1e4270f875ee |
parent 55033 | c72451a9f67e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
3 |
* |
|
4 |
* This code is free software; you can redistribute it and/or modify it |
|
5 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 6 |
* published by the Free Software Foundation. Oracle designates this |
2 | 7 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 8 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 9 |
* |
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
5506 | 20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
2 | 23 |
*/ |
24 |
||
25 |
/* |
|
26 |
* This file is available under and governed by the GNU General Public |
|
27 |
* License version 2 only, as published by the Free Software Foundation. |
|
28 |
* However, the following notice accompanied the original version of this |
|
29 |
* file: |
|
30 |
* |
|
31 |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
|
32 |
* Expert Group and released to the public domain, as explained at |
|
9242
ef138d47df58
7034657: Update Creative Commons license URL in legal notices
dl
parents:
5506
diff
changeset
|
33 |
* http://creativecommons.org/publicdomain/zero/1.0/ |
2 | 34 |
*/ |
35 |
||
36 |
package java.util.concurrent.atomic; |
|
32838
caeef2c79243
8134854: Bulk integration of java.util.concurrent.atomic classes
dl
parents:
25859
diff
changeset
|
37 |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
38 |
import java.lang.invoke.VarHandle; |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
39 |
import java.util.function.LongBinaryOperator; |
32838
caeef2c79243
8134854: Bulk integration of java.util.concurrent.atomic classes
dl
parents:
25859
diff
changeset
|
40 |
import java.util.function.LongUnaryOperator; |
58138
1e4270f875ee
8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents:
55033
diff
changeset
|
41 |
import jdk.internal.misc.Unsafe; |
2 | 42 |
|
43 |
/** |
|
44 |
* A {@code long} value that may be updated atomically. See the |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
45 |
* {@link VarHandle} specification for descriptions of the properties |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
46 |
* of atomic accesses. An {@code AtomicLong} is used in applications |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
47 |
* such as atomically incremented sequence numbers, and cannot be used |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
48 |
* as a replacement for a {@link java.lang.Long}. However, this class |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
49 |
* does extend {@code Number} to allow uniform access by tools and |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
50 |
* utilities that deal with numerically-based classes. |
2 | 51 |
* |
52 |
* @since 1.5 |
|
53 |
* @author Doug Lea |
|
54 |
*/ |
|
55 |
public class AtomicLong extends Number implements java.io.Serializable { |
|
56 |
private static final long serialVersionUID = 1927816293512124184L; |
|
57 |
||
58 |
/** |
|
59 |
* Records whether the underlying JVM supports lockless |
|
45518
4a116dd82fb5
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
41415
diff
changeset
|
60 |
* compareAndSet for longs. While the intrinsic compareAndSetLong |
2 | 61 |
* method works in either case, some constructions should be |
62 |
* handled at Java level to avoid locking user-visible locks. |
|
63 |
*/ |
|
64 |
static final boolean VM_SUPPORTS_LONG_CAS = VMSupportsCS8(); |
|
65 |
||
66 |
/** |
|
67 |
* Returns whether underlying JVM supports lockless CompareAndSet |
|
68 |
* for longs. Called only once and cached in VM_SUPPORTS_LONG_CAS. |
|
69 |
*/ |
|
70 |
private static native boolean VMSupportsCS8(); |
|
71 |
||
39777 | 72 |
/* |
73 |
* This class intended to be implemented using VarHandles, but there |
|
74 |
* are unresolved cyclic startup dependencies. |
|
75 |
*/ |
|
58138
1e4270f875ee
8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents:
55033
diff
changeset
|
76 |
private static final Unsafe U = Unsafe.getUnsafe(); |
1e4270f875ee
8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents:
55033
diff
changeset
|
77 |
private static final long VALUE |
1e4270f875ee
8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents:
55033
diff
changeset
|
78 |
= U.objectFieldOffset(AtomicLong.class, "value"); |
2 | 79 |
|
80 |
private volatile long value; |
|
81 |
||
82 |
/** |
|
83 |
* Creates a new AtomicLong with the given initial value. |
|
84 |
* |
|
85 |
* @param initialValue the initial value |
|
86 |
*/ |
|
87 |
public AtomicLong(long initialValue) { |
|
88 |
value = initialValue; |
|
89 |
} |
|
90 |
||
91 |
/** |
|
92 |
* Creates a new AtomicLong with initial value {@code 0}. |
|
93 |
*/ |
|
94 |
public AtomicLong() { |
|
95 |
} |
|
96 |
||
97 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
98 |
* Returns the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
99 |
* with memory effects as specified by {@link VarHandle#getVolatile}. |
2 | 100 |
* |
101 |
* @return the current value |
|
102 |
*/ |
|
103 |
public final long get() { |
|
104 |
return value; |
|
105 |
} |
|
106 |
||
107 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
108 |
* Sets the value to {@code newValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
109 |
* with memory effects as specified by {@link VarHandle#setVolatile}. |
2 | 110 |
* |
111 |
* @param newValue the new value |
|
112 |
*/ |
|
113 |
public final void set(long newValue) { |
|
45637
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
114 |
// See JDK-8180620: Clarify VarHandle mixed-access subtleties |
39777 | 115 |
U.putLongVolatile(this, VALUE, newValue); |
2 | 116 |
} |
117 |
||
118 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
119 |
* Sets the value to {@code newValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
120 |
* with memory effects as specified by {@link VarHandle#setRelease}. |
2 | 121 |
* |
122 |
* @param newValue the new value |
|
123 |
* @since 1.6 |
|
124 |
*/ |
|
125 |
public final void lazySet(long newValue) { |
|
39777 | 126 |
U.putLongRelease(this, VALUE, newValue); |
2 | 127 |
} |
128 |
||
129 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
130 |
* Atomically sets the value to {@code newValue} and returns the old value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
131 |
* with memory effects as specified by {@link VarHandle#getAndSet}. |
2 | 132 |
* |
133 |
* @param newValue the new value |
|
134 |
* @return the previous value |
|
135 |
*/ |
|
136 |
public final long getAndSet(long newValue) { |
|
39777 | 137 |
return U.getAndSetLong(this, VALUE, newValue); |
2 | 138 |
} |
139 |
||
140 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
141 |
* Atomically sets the value to {@code newValue} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
142 |
* if the current value {@code == expectedValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
143 |
* with memory effects as specified by {@link VarHandle#compareAndSet}. |
2 | 144 |
* |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
145 |
* @param expectedValue the expected value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
146 |
* @param newValue the new value |
18576 | 147 |
* @return {@code true} if successful. False return indicates that |
2 | 148 |
* the actual value was not equal to the expected value. |
149 |
*/ |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
150 |
public final boolean compareAndSet(long expectedValue, long newValue) { |
45518
4a116dd82fb5
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
41415
diff
changeset
|
151 |
return U.compareAndSetLong(this, VALUE, expectedValue, newValue); |
2 | 152 |
} |
153 |
||
154 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
155 |
* Possibly atomically sets the value to {@code newValue} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
156 |
* if the current value {@code == expectedValue}, |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
157 |
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. |
2 | 158 |
* |
41415
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
159 |
* @deprecated This method has plain memory effects but the method |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
160 |
* name implies volatile memory effects (see methods such as |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
161 |
* {@link #compareAndExchange} and {@link #compareAndSet}). To avoid |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
162 |
* confusion over plain or volatile memory effects it is recommended that |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
163 |
* the method {@link #weakCompareAndSetPlain} be used instead. |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
164 |
* |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
165 |
* @param expectedValue the expected value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
166 |
* @param newValue the new value |
18576 | 167 |
* @return {@code true} if successful |
41415
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
168 |
* @see #weakCompareAndSetPlain |
2 | 169 |
*/ |
41415
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
170 |
@Deprecated(since="9") |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
171 |
public final boolean weakCompareAndSet(long expectedValue, long newValue) { |
45518
4a116dd82fb5
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
41415
diff
changeset
|
172 |
return U.weakCompareAndSetLongPlain(this, VALUE, expectedValue, newValue); |
2 | 173 |
} |
174 |
||
175 |
/** |
|
41415
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
176 |
* Possibly atomically sets the value to {@code newValue} |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
177 |
* if the current value {@code == expectedValue}, |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
178 |
* with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
179 |
* |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
180 |
* @param expectedValue the expected value |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
181 |
* @param newValue the new value |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
182 |
* @return {@code true} if successful |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
183 |
* @since 9 |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
184 |
*/ |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
185 |
public final boolean weakCompareAndSetPlain(long expectedValue, long newValue) { |
45518
4a116dd82fb5
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
41415
diff
changeset
|
186 |
return U.weakCompareAndSetLongPlain(this, VALUE, expectedValue, newValue); |
41415
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
187 |
} |
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
188 |
|
9c298252e385
8164814: Deprecate Atomic*.weakCompareAndSet and defer to Atomic*.weakCompareAndSetPlain
psandoz
parents:
40734
diff
changeset
|
189 |
/** |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
190 |
* Atomically increments the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
191 |
* with memory effects as specified by {@link VarHandle#getAndAdd}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
192 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
193 |
* <p>Equivalent to {@code getAndAdd(1)}. |
2 | 194 |
* |
195 |
* @return the previous value |
|
196 |
*/ |
|
197 |
public final long getAndIncrement() { |
|
39777 | 198 |
return U.getAndAddLong(this, VALUE, 1L); |
2 | 199 |
} |
200 |
||
201 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
202 |
* Atomically decrements the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
203 |
* with memory effects as specified by {@link VarHandle#getAndAdd}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
204 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
205 |
* <p>Equivalent to {@code getAndAdd(-1)}. |
2 | 206 |
* |
207 |
* @return the previous value |
|
208 |
*/ |
|
209 |
public final long getAndDecrement() { |
|
39777 | 210 |
return U.getAndAddLong(this, VALUE, -1L); |
2 | 211 |
} |
212 |
||
213 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
214 |
* Atomically adds the given value to the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
215 |
* with memory effects as specified by {@link VarHandle#getAndAdd}. |
2 | 216 |
* |
217 |
* @param delta the value to add |
|
218 |
* @return the previous value |
|
219 |
*/ |
|
220 |
public final long getAndAdd(long delta) { |
|
39777 | 221 |
return U.getAndAddLong(this, VALUE, delta); |
2 | 222 |
} |
223 |
||
224 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
225 |
* Atomically increments the current value, |
40733 | 226 |
* with memory effects as specified by {@link VarHandle#getAndAdd}. |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
227 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
228 |
* <p>Equivalent to {@code addAndGet(1)}. |
2 | 229 |
* |
230 |
* @return the updated value |
|
231 |
*/ |
|
232 |
public final long incrementAndGet() { |
|
39777 | 233 |
return U.getAndAddLong(this, VALUE, 1L) + 1L; |
2 | 234 |
} |
235 |
||
236 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
237 |
* Atomically decrements the current value, |
40733 | 238 |
* with memory effects as specified by {@link VarHandle#getAndAdd}. |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
239 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
240 |
* <p>Equivalent to {@code addAndGet(-1)}. |
2 | 241 |
* |
242 |
* @return the updated value |
|
243 |
*/ |
|
244 |
public final long decrementAndGet() { |
|
39777 | 245 |
return U.getAndAddLong(this, VALUE, -1L) - 1L; |
2 | 246 |
} |
247 |
||
248 |
/** |
|
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
249 |
* Atomically adds the given value to the current value, |
40733 | 250 |
* with memory effects as specified by {@link VarHandle#getAndAdd}. |
2 | 251 |
* |
252 |
* @param delta the value to add |
|
253 |
* @return the updated value |
|
254 |
*/ |
|
255 |
public final long addAndGet(long delta) { |
|
39777 | 256 |
return U.getAndAddLong(this, VALUE, delta) + delta; |
2 | 257 |
} |
258 |
||
259 |
/** |
|
45637
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
260 |
* Atomically updates (with memory effects as specified by {@link |
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
261 |
* VarHandle#compareAndSet}) the current value with the results of |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
262 |
* applying the given function, returning the previous value. The |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
263 |
* function should be side-effect-free, since it may be re-applied |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
264 |
* when attempted updates fail due to contention among threads. |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
265 |
* |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
266 |
* @param updateFunction a side-effect-free function |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
267 |
* @return the previous value |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
268 |
* @since 1.8 |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
269 |
*/ |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
270 |
public final long getAndUpdate(LongUnaryOperator updateFunction) { |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
271 |
long prev = get(), next = 0L; |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
272 |
for (boolean haveNext = false;;) { |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
273 |
if (!haveNext) |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
274 |
next = updateFunction.applyAsLong(prev); |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
275 |
if (weakCompareAndSetVolatile(prev, next)) |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
276 |
return prev; |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
277 |
haveNext = (prev == (prev = get())); |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
278 |
} |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
279 |
} |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
280 |
|
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
281 |
/** |
45637
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
282 |
* Atomically updates (with memory effects as specified by {@link |
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
283 |
* VarHandle#compareAndSet}) the current value with the results of |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
284 |
* applying the given function, returning the updated value. The |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
285 |
* function should be side-effect-free, since it may be re-applied |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
286 |
* when attempted updates fail due to contention among threads. |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
287 |
* |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
288 |
* @param updateFunction a side-effect-free function |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
289 |
* @return the updated value |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
290 |
* @since 1.8 |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
291 |
*/ |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
292 |
public final long updateAndGet(LongUnaryOperator updateFunction) { |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
293 |
long prev = get(), next = 0L; |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
294 |
for (boolean haveNext = false;;) { |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
295 |
if (!haveNext) |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
296 |
next = updateFunction.applyAsLong(prev); |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
297 |
if (weakCompareAndSetVolatile(prev, next)) |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
298 |
return next; |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
299 |
haveNext = (prev == (prev = get())); |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
300 |
} |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
301 |
} |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
302 |
|
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
303 |
/** |
45637
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
304 |
* Atomically updates (with memory effects as specified by {@link |
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
305 |
* VarHandle#compareAndSet}) the current value with the results of |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
306 |
* applying the given function to the current and given values, |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
307 |
* returning the previous value. The function should be |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
308 |
* side-effect-free, since it may be re-applied when attempted |
45637
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
309 |
* updates fail due to contention among threads. The function is |
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
310 |
* applied with the current value as its first argument, and the |
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
311 |
* given update as the second argument. |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
312 |
* |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
313 |
* @param x the update value |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
314 |
* @param accumulatorFunction a side-effect-free function of two arguments |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
315 |
* @return the previous value |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
316 |
* @since 1.8 |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
317 |
*/ |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
318 |
public final long getAndAccumulate(long x, |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
319 |
LongBinaryOperator accumulatorFunction) { |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
320 |
long prev = get(), next = 0L; |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
321 |
for (boolean haveNext = false;;) { |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
322 |
if (!haveNext) |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
323 |
next = accumulatorFunction.applyAsLong(prev, x); |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
324 |
if (weakCompareAndSetVolatile(prev, next)) |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
325 |
return prev; |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
326 |
haveNext = (prev == (prev = get())); |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
327 |
} |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
328 |
} |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
329 |
|
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
330 |
/** |
45637
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
331 |
* Atomically updates (with memory effects as specified by {@link |
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
332 |
* VarHandle#compareAndSet}) the current value with the results of |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
333 |
* applying the given function to the current and given values, |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
334 |
* returning the updated value. The function should be |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
335 |
* side-effect-free, since it may be re-applied when attempted |
45637
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
336 |
* updates fail due to contention among threads. The function is |
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
337 |
* applied with the current value as its first argument, and the |
9e0c80381e32
8181104: Fix specs for updateAndGet and related methods
dl
parents:
45518
diff
changeset
|
338 |
* given update as the second argument. |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
339 |
* |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
340 |
* @param x the update value |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
341 |
* @param accumulatorFunction a side-effect-free function of two arguments |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
342 |
* @return the updated value |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
343 |
* @since 1.8 |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
344 |
*/ |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
345 |
public final long accumulateAndGet(long x, |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
346 |
LongBinaryOperator accumulatorFunction) { |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
347 |
long prev = get(), next = 0L; |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
348 |
for (boolean haveNext = false;;) { |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
349 |
if (!haveNext) |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
350 |
next = accumulatorFunction.applyAsLong(prev, x); |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
351 |
if (weakCompareAndSetVolatile(prev, next)) |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
352 |
return next; |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
353 |
haveNext = (prev == (prev = get())); |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
354 |
} |
15267
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
355 |
} |
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
356 |
|
c884f548a25f
8001666: Add lambda-compatible atomics and accumulators to the ActomicXXX classes
dl
parents:
15020
diff
changeset
|
357 |
/** |
2 | 358 |
* Returns the String representation of the current value. |
15020
50394fa17c1b
8006007: j.u.c.atomic classes should use intrinsic getAndXXX provided by 7023898
chegar
parents:
14325
diff
changeset
|
359 |
* @return the String representation of the current value |
2 | 360 |
*/ |
361 |
public String toString() { |
|
362 |
return Long.toString(get()); |
|
363 |
} |
|
364 |
||
10067
1263ecd22db6
6253144: Long narrowing conversion should describe the algorithm used and implied "risks"
darcy
parents:
9242
diff
changeset
|
365 |
/** |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
366 |
* Returns the current value of this {@code AtomicLong} as an {@code int} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
367 |
* after a narrowing primitive conversion, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
368 |
* with memory effects as specified by {@link VarHandle#getVolatile}. |
55033
c72451a9f67e
8224176: Fix inconsistencies in @jls tags in java.util.concurrent
dl
parents:
47216
diff
changeset
|
369 |
* @jls 5.1.3 Narrowing Primitive Conversion |
10067
1263ecd22db6
6253144: Long narrowing conversion should describe the algorithm used and implied "risks"
darcy
parents:
9242
diff
changeset
|
370 |
*/ |
2 | 371 |
public int intValue() { |
372 |
return (int)get(); |
|
373 |
} |
|
374 |
||
10067
1263ecd22db6
6253144: Long narrowing conversion should describe the algorithm used and implied "risks"
darcy
parents:
9242
diff
changeset
|
375 |
/** |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
376 |
* Returns the current value of this {@code AtomicLong} as a {@code long}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
377 |
* with memory effects as specified by {@link VarHandle#getVolatile}. |
32838
caeef2c79243
8134854: Bulk integration of java.util.concurrent.atomic classes
dl
parents:
25859
diff
changeset
|
378 |
* Equivalent to {@link #get()}. |
10067
1263ecd22db6
6253144: Long narrowing conversion should describe the algorithm used and implied "risks"
darcy
parents:
9242
diff
changeset
|
379 |
*/ |
2 | 380 |
public long longValue() { |
381 |
return get(); |
|
382 |
} |
|
383 |
||
10067
1263ecd22db6
6253144: Long narrowing conversion should describe the algorithm used and implied "risks"
darcy
parents:
9242
diff
changeset
|
384 |
/** |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
385 |
* Returns the current value of this {@code AtomicLong} as a {@code float} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
386 |
* after a widening primitive conversion, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
387 |
* with memory effects as specified by {@link VarHandle#getVolatile}. |
55033
c72451a9f67e
8224176: Fix inconsistencies in @jls tags in java.util.concurrent
dl
parents:
47216
diff
changeset
|
388 |
* @jls 5.1.2 Widening Primitive Conversion |
10067
1263ecd22db6
6253144: Long narrowing conversion should describe the algorithm used and implied "risks"
darcy
parents:
9242
diff
changeset
|
389 |
*/ |
2 | 390 |
public float floatValue() { |
391 |
return (float)get(); |
|
392 |
} |
|
393 |
||
10067
1263ecd22db6
6253144: Long narrowing conversion should describe the algorithm used and implied "risks"
darcy
parents:
9242
diff
changeset
|
394 |
/** |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
395 |
* Returns the current value of this {@code AtomicLong} as a {@code double} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
396 |
* after a widening primitive conversion, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
397 |
* with memory effects as specified by {@link VarHandle#getVolatile}. |
55033
c72451a9f67e
8224176: Fix inconsistencies in @jls tags in java.util.concurrent
dl
parents:
47216
diff
changeset
|
398 |
* @jls 5.1.2 Widening Primitive Conversion |
10067
1263ecd22db6
6253144: Long narrowing conversion should describe the algorithm used and implied "risks"
darcy
parents:
9242
diff
changeset
|
399 |
*/ |
2 | 400 |
public double doubleValue() { |
401 |
return (double)get(); |
|
402 |
} |
|
403 |
||
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
404 |
// jdk9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
405 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
406 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
407 |
* Returns the current value, with memory semantics of reading as if the |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
408 |
* variable was declared non-{@code volatile}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
409 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
410 |
* @return the value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
411 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
412 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
413 |
public final long getPlain() { |
39777 | 414 |
return U.getLong(this, VALUE); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
415 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
416 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
417 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
418 |
* Sets the value to {@code newValue}, with memory semantics |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
419 |
* of setting as if the variable was declared non-{@code volatile} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
420 |
* and non-{@code final}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
421 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
422 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
423 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
424 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
425 |
public final void setPlain(long newValue) { |
39777 | 426 |
U.putLong(this, VALUE, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
427 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
428 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
429 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
430 |
* Returns the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
431 |
* with memory effects as specified by {@link VarHandle#getOpaque}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
432 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
433 |
* @return the value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
434 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
435 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
436 |
public final long getOpaque() { |
39777 | 437 |
return U.getLongOpaque(this, VALUE); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
438 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
439 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
440 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
441 |
* Sets the value to {@code newValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
442 |
* with memory effects as specified by {@link VarHandle#setOpaque}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
443 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
444 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
445 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
446 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
447 |
public final void setOpaque(long newValue) { |
39777 | 448 |
U.putLongOpaque(this, VALUE, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
449 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
450 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
451 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
452 |
* Returns the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
453 |
* with memory effects as specified by {@link VarHandle#getAcquire}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
454 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
455 |
* @return the value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
456 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
457 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
458 |
public final long getAcquire() { |
39777 | 459 |
return U.getLongAcquire(this, VALUE); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
460 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
461 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
462 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
463 |
* Sets the value to {@code newValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
464 |
* with memory effects as specified by {@link VarHandle#setRelease}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
465 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
466 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
467 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
468 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
469 |
public final void setRelease(long newValue) { |
39777 | 470 |
U.putLongRelease(this, VALUE, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
471 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
472 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
473 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
474 |
* Atomically sets the value to {@code newValue} if the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
475 |
* referred to as the <em>witness value</em>, {@code == expectedValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
476 |
* with memory effects as specified by |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
477 |
* {@link VarHandle#compareAndExchange}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
478 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
479 |
* @param expectedValue the expected value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
480 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
481 |
* @return the witness value, which will be the same as the |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
482 |
* expected value if successful |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
483 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
484 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
485 |
public final long compareAndExchange(long expectedValue, long newValue) { |
45518
4a116dd82fb5
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
41415
diff
changeset
|
486 |
return U.compareAndExchangeLong(this, VALUE, expectedValue, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
487 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
488 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
489 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
490 |
* Atomically sets the value to {@code newValue} if the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
491 |
* referred to as the <em>witness value</em>, {@code == expectedValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
492 |
* with memory effects as specified by |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
493 |
* {@link VarHandle#compareAndExchangeAcquire}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
494 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
495 |
* @param expectedValue the expected value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
496 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
497 |
* @return the witness value, which will be the same as the |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
498 |
* expected value if successful |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
499 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
500 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
501 |
public final long compareAndExchangeAcquire(long expectedValue, long newValue) { |
39777 | 502 |
return U.compareAndExchangeLongAcquire(this, VALUE, expectedValue, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
503 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
504 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
505 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
506 |
* Atomically sets the value to {@code newValue} if the current value, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
507 |
* referred to as the <em>witness value</em>, {@code == expectedValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
508 |
* with memory effects as specified by |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
509 |
* {@link VarHandle#compareAndExchangeRelease}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
510 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
511 |
* @param expectedValue the expected value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
512 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
513 |
* @return the witness value, which will be the same as the |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
514 |
* expected value if successful |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
515 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
516 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
517 |
public final long compareAndExchangeRelease(long expectedValue, long newValue) { |
39777 | 518 |
return U.compareAndExchangeLongRelease(this, VALUE, expectedValue, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
519 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
520 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
521 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
522 |
* Possibly atomically sets the value to {@code newValue} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
523 |
* if the current value {@code == expectedValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
524 |
* with memory effects as specified by |
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
525 |
* {@link VarHandle#weakCompareAndSet}. |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
526 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
527 |
* @param expectedValue the expected value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
528 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
529 |
* @return {@code true} if successful |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
530 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
531 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
532 |
public final boolean weakCompareAndSetVolatile(long expectedValue, long newValue) { |
45518
4a116dd82fb5
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
41415
diff
changeset
|
533 |
return U.weakCompareAndSetLong(this, VALUE, expectedValue, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
534 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
535 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
536 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
537 |
* Possibly atomically sets the value to {@code newValue} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
538 |
* if the current value {@code == expectedValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
539 |
* with memory effects as specified by |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
540 |
* {@link VarHandle#weakCompareAndSetAcquire}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
541 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
542 |
* @param expectedValue the expected value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
543 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
544 |
* @return {@code true} if successful |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
545 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
546 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
547 |
public final boolean weakCompareAndSetAcquire(long expectedValue, long newValue) { |
45518
4a116dd82fb5
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
41415
diff
changeset
|
548 |
return U.weakCompareAndSetLongAcquire(this, VALUE, expectedValue, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
549 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
550 |
|
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
551 |
/** |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
552 |
* Possibly atomically sets the value to {@code newValue} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
553 |
* if the current value {@code == expectedValue}, |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
554 |
* with memory effects as specified by |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
555 |
* {@link VarHandle#weakCompareAndSetRelease}. |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
556 |
* |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
557 |
* @param expectedValue the expected value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
558 |
* @param newValue the new value |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
559 |
* @return {@code true} if successful |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
560 |
* @since 9 |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
561 |
*/ |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
562 |
public final boolean weakCompareAndSetRelease(long expectedValue, long newValue) { |
45518
4a116dd82fb5
8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents:
41415
diff
changeset
|
563 |
return U.weakCompareAndSetLongRelease(this, VALUE, expectedValue, newValue); |
39725
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
564 |
} |
9548f8d846e9
8080603: Replace Unsafe with VarHandle in java.util.concurrent classes
dl
parents:
36936
diff
changeset
|
565 |
|
2 | 566 |
} |