diff options
author | Seth Tisue <seth@tisue.net> | 2015-08-06 16:04:34 -0700 |
---|---|---|
committer | Seth Tisue <seth@tisue.net> | 2015-08-06 16:04:34 -0700 |
commit | 16bc9b75cec01eccff8448b6a11e968f1a35e7a7 (patch) | |
tree | b263e4984ecffc1006d165ccabbf92767b0697cf /src/library | |
parent | fd5a8bf1a1ef6e4b31afc9a4f38a597152cfe431 (diff) | |
parent | c201eac291682a9bdb9ca2790403084b4f36da76 (diff) | |
download | scala-16bc9b75cec01eccff8448b6a11e968f1a35e7a7.tar.gz scala-16bc9b75cec01eccff8448b6a11e968f1a35e7a7.tar.bz2 scala-16bc9b75cec01eccff8448b6a11e968f1a35e7a7.zip |
Merge pull request #4443 from adriaanm/abstractpromise-avoid-unsafe
SI-8362: AbstractPromise extends AtomicReference, avoids sun.misc.Unsafe
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/concurrent/impl/AbstractPromise.java | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/src/library/scala/concurrent/impl/AbstractPromise.java b/src/library/scala/concurrent/impl/AbstractPromise.java index b8165b6cde..c2520a1692 100644 --- a/src/library/scala/concurrent/impl/AbstractPromise.java +++ b/src/library/scala/concurrent/impl/AbstractPromise.java @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2015, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -8,33 +8,10 @@ package scala.concurrent.impl; +import java.util.concurrent.atomic.AtomicReference; -import scala.concurrent.util.Unsafe; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; - - - -abstract class AbstractPromise { - private volatile Object _ref; - - final static long _refoffset; - - static { - try { - _refoffset = Unsafe.instance.objectFieldOffset(AbstractPromise.class.getDeclaredField("_ref")); - } catch (Throwable t) { - throw new ExceptionInInitializerError(t); - } - } - - protected final boolean updateState(Object oldState, Object newState) { - return Unsafe.instance.compareAndSwapObject(this, _refoffset, oldState, newState); - } - - protected final Object getState() { - return _ref; - } - - protected final static AtomicReferenceFieldUpdater<AbstractPromise, Object> updater = - AtomicReferenceFieldUpdater.newUpdater(AbstractPromise.class, Object.class, "_ref"); -}
\ No newline at end of file +@Deprecated // Since 2.11.8. Extend java.util.concurrent.atomic.AtomicReference instead. +abstract class AbstractPromise extends AtomicReference<Object> { + protected final boolean updateState(Object oldState, Object newState) { return compareAndSet(oldState, newState); } + protected final Object getState() { return get(); } +} |