Skip to content

Commit 4897063

Browse files
committed
SI-6932 Remove Batchable trait, minor clean-ups, update build
1 parent 5713c1b commit 4897063

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ LOCAL REFERENCE BUILD (LOCKER)
401401
<exclude name="scala/concurrent/Promise.scala"/>
402402
<exclude name="scala/concurrent/ExecutionContext.scala"/>
403403
<exclude name="scala/concurrent/BlockContext.scala"/>
404+
<exclude name="scala/concurrent/BatchingExecutor.scala"/>
404405
<exclude name="scala/concurrent/impl/Future.scala"/>
405406
<exclude name="scala/concurrent/impl/Promise.scala"/>
406407
<exclude name="scala/concurrent/impl/ExecutionContextImpl.scala"/>

src/library/scala/concurrent/BatchingExecutor.scala

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,9 @@
88

99
package scala.concurrent
1010

11-
import java.util.concurrent.{ Executor }
12-
import scala.concurrent._
11+
import java.util.concurrent.Executor
1312
import scala.annotation.tailrec
1413

15-
/**
16-
* All Batchables are automatically batched when submitted to a BatchingExecutor
17-
*/
18-
private[concurrent] trait Batchable extends Runnable {
19-
def isBatchable: Boolean
20-
}
21-
2214
/**
2315
* Mixin trait for an Executor
2416
* which groups multiple nested `Runnable.run()` calls
@@ -64,13 +56,13 @@ private[concurrent] trait BatchingExecutor extends Executor {
6456
parentBlockContext = prevBlockContext
6557

6658
@tailrec def processBatch(batch: List[Runnable]): Unit = batch match {
67-
case Nil ()
68-
case head :: tail
59+
case Nil => ()
60+
case head :: tail =>
6961
_tasksLocal set tail
7062
try {
7163
head.run()
7264
} catch {
73-
case t: Throwable
65+
case t: Throwable =>
7466
// if one task throws, move the
7567
// remaining tasks to another thread
7668
// so we can throw the exception
@@ -91,7 +83,7 @@ private[concurrent] trait BatchingExecutor extends Executor {
9183
}
9284
}
9385

94-
override def blockOn[T](thunk: T)(implicit permission: CanAwait): T = {
86+
override def blockOn[T](thunk: => T)(implicit permission: CanAwait): T = {
9587
// if we know there will be blocking, we don't want to keep tasks queued up because it could deadlock.
9688
{
9789
val tasks = _tasksLocal.get
@@ -111,16 +103,15 @@ private[concurrent] trait BatchingExecutor extends Executor {
111103
override def execute(runnable: Runnable): Unit = {
112104
if (batchable(runnable)) { // If we can batch the runnable
113105
_tasksLocal.get match {
114-
case null unbatchedExecute(new Batch(List(runnable))) // If we aren't in batching mode yet, enqueue batch
115-
case some _tasksLocal.set(runnable :: some) // If we are already in batching mode, add to batch
106+
case null => unbatchedExecute(new Batch(List(runnable))) // If we aren't in batching mode yet, enqueue batch
107+
case some => _tasksLocal.set(runnable :: some) // If we are already in batching mode, add to batch
116108
}
117109
} else unbatchedExecute(runnable) // If not batchable, just delegate to underlying
118110
}
119111

120112
/** Override this to define which runnables will be batched. */
121113
def batchable(runnable: Runnable): Boolean = runnable match {
122-
case b: Batchable b.isBatchable
123-
case _: scala.concurrent.OnCompleteRunnable true
124-
case _ false
114+
case _: OnCompleteRunnable => true
115+
case _ => false
125116
}
126117
}

0 commit comments

Comments
 (0)