Removing all uses of immutable.Stack in Akka

This commit is contained in:
Viktor Klang 2012-06-13 14:08:47 +02:00
parent 2d4067e21e
commit d6e3642d9d
4 changed files with 8 additions and 13 deletions

View file

@ -7,7 +7,6 @@ package akka.actor
import akka.AkkaException import akka.AkkaException
import scala.reflect.BeanProperty import scala.reflect.BeanProperty
import scala.util.control.NoStackTrace import scala.util.control.NoStackTrace
import scala.collection.immutable.Stack
import java.util.regex.Pattern import java.util.regex.Pattern
/** /**

View file

@ -13,7 +13,6 @@ import java.io.Closeable
import akka.dispatch.Await.{ Awaitable, CanAwait } import akka.dispatch.Await.{ Awaitable, CanAwait }
import akka.util._ import akka.util._
import akka.util.internal.{ HashedWheelTimer, ConcurrentIdentityHashMap } import akka.util.internal.{ HashedWheelTimer, ConcurrentIdentityHashMap }
import collection.immutable.Stack
import java.util.concurrent.{ ThreadFactory, CountDownLatch, TimeoutException, RejectedExecutionException } import java.util.concurrent.{ ThreadFactory, CountDownLatch, TimeoutException, RejectedExecutionException }
import java.util.concurrent.TimeUnit.MILLISECONDS import java.util.concurrent.TimeUnit.MILLISECONDS
@ -685,8 +684,8 @@ private[akka] class ActorSystemImpl(val name: String, applicationConfig: Config,
final class TerminationCallbacks extends Runnable with Awaitable[Unit] { final class TerminationCallbacks extends Runnable with Awaitable[Unit] {
private val lock = new ReentrantGuard private val lock = new ReentrantGuard
private var callbacks: Stack[Runnable] = _ //non-volatile since guarded by the lock private var callbacks: List[Runnable] = _ //non-volatile since guarded by the lock
lock withGuard { callbacks = Stack.empty[Runnable] } lock withGuard { callbacks = Nil }
private val latch = new CountDownLatch(1) private val latch = new CountDownLatch(1)
@ -695,17 +694,17 @@ private[akka] class ActorSystemImpl(val name: String, applicationConfig: Config,
case 0 throw new RejectedExecutionException("Must be called prior to system shutdown.") case 0 throw new RejectedExecutionException("Must be called prior to system shutdown.")
case _ lock withGuard { case _ lock withGuard {
if (latch.getCount == 0) throw new RejectedExecutionException("Must be called prior to system shutdown.") if (latch.getCount == 0) throw new RejectedExecutionException("Must be called prior to system shutdown.")
else callbacks = callbacks.push(callback) else callbacks ::= callback
} }
} }
} }
final def run(): Unit = lock withGuard { final def run(): Unit = lock withGuard {
@tailrec def runNext(c: Stack[Runnable]): Stack[Runnable] = c.headOption match { @tailrec def runNext(c: List[Runnable]): List[Runnable] = c match {
case None Stack.empty[Runnable] case Nil Nil
case Some(callback) case callback :: _
try callback.run() catch { case e log.error(e, "Failed to run termination callback, due to [{}]", e.getMessage) } try callback.run() catch { case NonFatal(e) log.error(e, "Failed to run termination callback, due to [{}]", e.getMessage) }
runNext(c.pop) runNext(c.tail)
} }
try { callbacks = runNext(callbacks) } finally latch.countDown() try { callbacks = runNext(callbacks) } finally latch.countDown()
} }

View file

@ -6,7 +6,6 @@ package akka.actor
import akka.dispatch._ import akka.dispatch._
import akka.japi.Creator import akka.japi.Creator
import collection.immutable.Stack
import akka.routing._ import akka.routing._
/** /**

View file

@ -5,9 +5,7 @@
package akka.testkit package akka.testkit
import akka.actor._ import akka.actor._
import akka.util.Duration
import java.util.concurrent.atomic.AtomicLong import java.util.concurrent.atomic.AtomicLong
import scala.collection.immutable.Stack
import akka.dispatch._ import akka.dispatch._
import akka.pattern.ask import akka.pattern.ask