summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/parallel/Tasks.scala
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-10-20 20:20:00 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-10-20 20:20:00 +0000
commite7ca142b45255f6b41582c25fe590a664d5fc8b9 (patch)
treea674b7cc69ad247330d444f4011a55d6a7ce61e2 /src/library/scala/collection/parallel/Tasks.scala
parentd3d218e5ea77584489437f0dfa8148ee3764d6f7 (diff)
downloadscala-e7ca142b45255f6b41582c25fe590a664d5fc8b9.tar.gz
scala-e7ca142b45255f6b41582c25fe590a664d5fc8b9.tar.bz2
scala-e7ca142b45255f6b41582c25fe590a664d5fc8b9.zip
Some exception handling fixes in parallel colle...
Some exception handling fixes in parallel collections. Fixed some regressions. Fixed some tests. No review.
Diffstat (limited to 'src/library/scala/collection/parallel/Tasks.scala')
-rw-r--r--src/library/scala/collection/parallel/Tasks.scala22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala
index 915e02f787..c58bc8b734 100644
--- a/src/library/scala/collection/parallel/Tasks.scala
+++ b/src/library/scala/collection/parallel/Tasks.scala
@@ -59,8 +59,8 @@ trait Tasks {
protected[this] def merge(that: Tp) {}
// exception handling mechanism
- var exception: Exception = null
- def forwardException = if (exception != null) throw exception
+ var throwable: Throwable = null
+ def forwardThrowable = if (throwable != null) throw throwable
// tries to do the leaf computation, storing the possible exception
protected def tryLeaf(result: Option[R]) {
try {
@@ -70,15 +70,21 @@ trait Tasks {
signalAbort
}
} catch {
- case e: Exception =>
- exception = e
+ case thr: Throwable =>
+ throwable = thr
signalAbort
}
}
protected[this] def tryMerge(t: Tp) {
val that = t.asInstanceOf[Task[R, Tp]]
- if (this.exception == null && that.exception == null) merge(that.repr)
- else if (that.exception != null) this.exception = that.exception
+ if (this.throwable == null && that.throwable == null) merge(t)
+ mergeThrowables(that)
+ }
+ private[parallel] def mergeThrowables(that: Task[_, _]) {
+ if (this.throwable != null && that.throwable != null) {
+ // merge exceptions, since there were multiple exceptions
+ this.throwable = this.throwable alongWith that.throwable
+ } else if (that.throwable != null) this.throwable = that.throwable
}
// override in concrete task implementations to signal abort to other tasks
private[parallel] def signalAbort {}
@@ -206,7 +212,7 @@ trait ForkJoinTasks extends Tasks with HavingForkJoinPool {
() => {
fjtask.join
- fjtask.forwardException
+ fjtask.forwardThrowable
fjtask.result
}
}
@@ -225,7 +231,7 @@ trait ForkJoinTasks extends Tasks with HavingForkJoinPool {
forkJoinPool.execute(fjtask)
}
fjtask.join
- fjtask.forwardException
+ fjtask.forwardThrowable
fjtask.result
}