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-24 08:25:24 +0100
commit48970634271b8e231991dcd053134e1932d55e1d (patch)
tree1f2793fdb066dedf38468e2dcbab5865c0d352d6
parent5713c1b9b5642bb1813f9e5816d31a1bc5d70c60 (diff)
downloadscala-48970634271b8e231991dcd053134e1932d55e1d.tar.gz
scala-48970634271b8e231991dcd053134e1932d55e1d.tar.bz2
scala-48970634271b8e231991dcd053134e1932d55e1d.zip
SI-6932 Remove Batchable trait, minor clean-ups, update build
-rw-r--r--build.xml1
-rw-r--r--src/library/scala/concurrent/BatchingExecutor.scala27
2 files changed, 10 insertions, 18 deletions
diff --git a/build.xml b/build.xml
index 9df0c98c1a..7489955cc7 100644
--- a/build.xml
+++ b/build.xml
@@ -401,6 +401,7 @@ LOCAL REFERENCE BUILD (LOCKER)
<exclude name="scala/concurrent/Promise.scala"/>
<exclude name="scala/concurrent/ExecutionContext.scala"/>
<exclude name="scala/concurrent/BlockContext.scala"/>
+ <exclude name="scala/concurrent/BatchingExecutor.scala"/>
<exclude name="scala/concurrent/impl/Future.scala"/>
<exclude name="scala/concurrent/impl/Promise.scala"/>
<exclude name="scala/concurrent/impl/ExecutionContextImpl.scala"/>
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
}
}