summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2013-01-21 19:47:08 +0100
committerPhilipp Haller <hallerp@gmail.com>2013-01-21 19:47:08 +0100
commit262d7ec854ee32327188c292b54dd94ba2c7010c (patch)
tree7a9cda5688615fb5bcf2093818d941579ab8d062
parent08a74e55c15a8102d2b9184b29c5bc7474a4dd91 (diff)
downloadscala-262d7ec854ee32327188c292b54dd94ba2c7010c.tar.gz
scala-262d7ec854ee32327188c292b54dd94ba2c7010c.tar.bz2
scala-262d7ec854ee32327188c292b54dd94ba2c7010c.zip
SI-6932 Remove Batchable trait plus minor clean-ups
-rw-r--r--src/library/scala/concurrent/BatchingExecutor.scala27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/library/scala/concurrent/BatchingExecutor.scala b/src/library/scala/concurrent/BatchingExecutor.scala
index 3ab4bd88c5..a0d7aaea47 100644
--- a/src/library/scala/concurrent/BatchingExecutor.scala
+++ b/src/library/scala/concurrent/BatchingExecutor.scala
@@ -8,18 +8,10 @@
package scala.concurrent
-import java.util.concurrent.{ Executor }
-import scala.concurrent._
+import java.util.concurrent.Executor
import scala.annotation.tailrec
/**
- * All Batchables are automatically batched when submitted to a BatchingExecutor
- */
-private[concurrent] trait Batchable extends Runnable {
- def isBatchable: Boolean
-}
-
-/**
* Mixin trait for an Executor
* which groups multiple nested `Runnable.run()` calls
* into a single Runnable passed to the original
@@ -64,13 +56,13 @@ private[concurrent] trait BatchingExecutor extends Executor {
parentBlockContext = prevBlockContext
@tailrec def processBatch(batch: List[Runnable]): Unit = batch match {
- case Nil ⇒ ()
- case head :: tail ⇒
+ case Nil => ()
+ case head :: tail =>
_tasksLocal set tail
try {
head.run()
} catch {
- case t: Throwable ⇒
+ case t: Throwable =>
// if one task throws, move the
// remaining tasks to another thread
// so we can throw the exception
@@ -91,7 +83,7 @@ private[concurrent] trait BatchingExecutor extends Executor {
}
}
- override def blockOn[T](thunk: ⇒ T)(implicit permission: CanAwait): T = {
+ override def blockOn[T](thunk: => T)(implicit permission: CanAwait): T = {
// if we know there will be blocking, we don't want to keep tasks queued up because it could deadlock.
{
val tasks = _tasksLocal.get
@@ -111,16 +103,15 @@ private[concurrent] trait BatchingExecutor extends Executor {
override def execute(runnable: Runnable): Unit = {
if (batchable(runnable)) { // If we can batch the runnable
_tasksLocal.get match {
- case null ⇒ unbatchedExecute(new Batch(List(runnable))) // If we aren't in batching mode yet, enqueue batch
- case some ⇒ _tasksLocal.set(runnable :: some) // If we are already in batching mode, add to batch
+ case null => unbatchedExecute(new Batch(List(runnable))) // If we aren't in batching mode yet, enqueue batch
+ case some => _tasksLocal.set(runnable :: some) // If we are already in batching mode, add to batch
}
} else unbatchedExecute(runnable) // If not batchable, just delegate to underlying
}
/** Override this to define which runnables will be batched. */
def batchable(runnable: Runnable): Boolean = runnable match {
- case b: Batchable ⇒ b.isBatchable
- case _: scala.concurrent.OnCompleteRunnable ⇒ true
- case _ ⇒ false
+ case _: OnCompleteRunnable => true
+ case _ => false
}
}