summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorViktor Klang <viktor.klang@gmail.com>2012-04-13 17:33:34 +0200
committerViktor Klang <viktor.klang@gmail.com>2012-04-13 17:33:34 +0200
commit05779d413ed8de3717307b78cccb413f0a687101 (patch)
treea307705607a8465e4aa87181df80a19de5663fea /src/library
parent828aa0aaa9288c57f4574ca267a38173d15c458f (diff)
downloadscala-05779d413ed8de3717307b78cccb413f0a687101.tar.gz
scala-05779d413ed8de3717307b78cccb413f0a687101.tar.bz2
scala-05779d413ed8de3717307b78cccb413f0a687101.zip
Replacing all ⇒ with => in Promise.scala and harmonized def value to use same match approach as def isCompleted
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala
index ef87f27d63..140cfa93a0 100644
--- a/src/library/scala/concurrent/impl/Promise.scala
+++ b/src/library/scala/concurrent/impl/Promise.scala
@@ -115,13 +115,13 @@ object Promise {
}
def value: Option[Either[Throwable, T]] = getState match {
- case _: List[_] ⇒ None
- case c: Either[_, _] ⇒ Some(c.asInstanceOf[Either[Throwable, T]])
+ case c: Either[_, _] => Some(c.asInstanceOf[Either[Throwable, T]])
+ case _ => None
}
override def isCompleted(): Boolean = getState match { // Cheaper than boxing result into Option due to "def value"
- case _: Either[_, _] ⇒ true
- case _ ⇒ false
+ case _: Either[_, _] => true
+ case _ => false
}
@inline
@@ -134,15 +134,15 @@ object Promise {
protected final def getState: AnyRef = updater.get(this)
def tryComplete(value: Either[Throwable, T]): Boolean = {
- val callbacks: List[Either[Throwable, T] ⇒ Unit] = {
+ val callbacks: List[Either[Throwable, T] => Unit] = {
try {
@tailrec
- def tryComplete(v: Either[Throwable, T]): List[Either[Throwable, T] ⇒ Unit] = {
+ def tryComplete(v: Either[Throwable, T]): List[Either[Throwable, T] => Unit] = {
getState match {
- case raw: List[_] ⇒
- val cur = raw.asInstanceOf[List[Either[Throwable, T] ⇒ Unit]]
+ case raw: List[_] =>
+ val cur = raw.asInstanceOf[List[Either[Throwable, T] => Unit]]
if (updateState(cur, v)) cur else tryComplete(v)
- case _ ⇒ null
+ case _ => null
}
}
tryComplete(resolveEither(value))
@@ -152,26 +152,26 @@ object Promise {
}
callbacks match {
- case null ⇒ false
- case cs if cs.isEmpty ⇒ true
- case cs ⇒ Future.dispatchFuture(executor, () ⇒ cs.foreach(f ⇒ notifyCompleted(f, value))); true
+ case null => false
+ case cs if cs.isEmpty => true
+ case cs => Future.dispatchFuture(executor, () => cs.foreach(f => notifyCompleted(f, value))); true
}
}
- def onComplete[U](func: Either[Throwable, T] ⇒ U): this.type = {
+ def onComplete[U](func: Either[Throwable, T] => U): this.type = {
@tailrec //Returns whether the future has already been completed or not
def tryAddCallback(): Either[Throwable, T] = {
val cur = getState
cur match {
- case r: Either[_, _] ⇒ r.asInstanceOf[Either[Throwable, T]]
- case listeners: List[_] ⇒ if (updateState(listeners, func :: listeners)) null else tryAddCallback()
+ case r: Either[_, _] => r.asInstanceOf[Either[Throwable, T]]
+ case listeners: List[_] => if (updateState(listeners, func :: listeners)) null else tryAddCallback()
}
}
tryAddCallback() match {
- case null ⇒ this
- case completed ⇒
- Future.dispatchFuture(executor, () ⇒ notifyCompleted(func, completed))
+ case null => this
+ case completed =>
+ Future.dispatchFuture(executor, () => notifyCompleted(func, completed))
this
}
}