summaryrefslogtreecommitdiff
path: root/examples/scala-js/scalalib/overrides/scala/concurrent/impl/AbstractPromise.scala
blob: 8ea135e4d75f42b1dd52c78dcf46012d9188a09d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package scala.concurrent.impl

/**
 * JavaScript specific implementation of AbstractPromise
 *
 * This basically implements a "CAS" in Scala for JavaScript. Its
 * implementation is trivial because there is no multi-threading.
 *
 * @author Tobias Schlatter
 */
abstract class AbstractPromise {

  private var state: AnyRef = _

  protected final
  def updateState(oldState: AnyRef, newState: AnyRef): Boolean = {
    if (state eq oldState) {
      state = newState
      true
    } else false
  }

  protected final def getState: AnyRef = state

}

object AbstractPromise {
  protected def updater = ???
}