From 05779d413ed8de3717307b78cccb413f0a687101 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 13 Apr 2012 17:33:34 +0200 Subject: Replacing all ⇒ with => in Promise.scala and harmonized def value to use same match approach as def isCompleted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/library/scala/concurrent/impl/Promise.scala | 36 ++++++++++++------------- 1 file 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 } } -- cgit v1.2.3