8000 SI-8362: AbstractPromise extends AtomicReference · scala/scala@034f1b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 034f1b1

Browse files
mchvadriaanm
authored andcommitted
SI-8362: AbstractPromise extends AtomicReference
To avoid sun.misc.Unsafe, which is not supported on Google App Engine. Deprecate AbstractPromise -- extend j.u.c.atomic.AtomicReference directly. AtomicReference.compareAndSet() should also provide better performance on HotSpot, which compiles it down to the machine's CAS instruction. The binary incompatible change is ok because it's in an internal package. I can't think of any real issue with adding a superclass (which contributes only final methods) to a class in an implementation package (as long as those methods were not introduced in any illicit subclasses of said class). Instead of changing DefaultPromise's super class, let's be more conservative, and do it closest to the source. This is both clearer and more focussed, leaving those subclasses of AbstractPromise we never heard of unaffected. Genesis of the commit: since the work on Future performance, AbstractPromise is using Unsafe breaking the ability for Future to be executed on GAE. At that time, viktorklang suggested to implement a fallback in case Unsafe is not available. carey proposed an implementation, and mchv submitted a patch, which was refined by adriaanm. Oh, implement AbstractPromise in Scala while we're at it.
1 parent 3cf7c95 commit 034f1b1

File tree

4 files changed

+27
-40
lines changed

4 files changed

+27
-40
lines changed

bincompat-backward.whitelist.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ filter {
208208
{
209209
matchName="scala.reflect.io.ZipArchive.scala$reflect$io$ZipArchive$$walkIterator"
210210
problemName=MissingMethodProblem
211+
},
212+
// SI-8362 - package-protected class in an impl package
213+
{
214+
matchName="scala.concurrent.impl.Promise$DefaultPromise"
215+
problemName=MissingTypesProblem
211216
}
212217
]
213218
}

bincompat-forward.whitelist.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ filter {
319319
{
320320
matchName="scala.util.Random.scala$util$Random$$nextAlphaNum$1"
321321
problemName=MissingMethodProblem
322+
},
323+
// see SI-8362 - package-protected class in an impl package
324+
{
325+
matchName="scala.concurrent.impl.Promise$DefaultPromise"
326+
problemName=MissingTypesProblem
322327
}
323328
]
324329
}

src/library/scala/concurrent/impl/AbstractPromise.java

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* __ *\
2+
** ________ ___ / / ___ Scala API **
3+
** / __/ __// _ | / / / _ | (c) 2003-2015, LAMP/EPFL **
4+
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
5+
** /____/\___/_/ |_/____/_/ | | **
6+
** |/ **
7+
\* */
8+
9+
package scala.concurrent.impl
10+
11+
import java.util.concurrent.atomic.AtomicReference
12+
13+
@deprecated("Extend java.util.concurrent.atomic.AtomicReference instead.", "2.11.7")
14+
private[impl] abstract class AbstractPromise extends AtomicReference[AnyRef] {
15+
protected final def updateState(oldState: AnyRef, newState: AnyRef): Boolean = compareAndSet(oldState, newState)
16+
protected final def getState(): AnyRef = get()
17+
}

0 commit comments

Comments
 (0)
0