Skip to content

Commit df6ff3c

Browse files
committed
Reuse tasksupport in CombinerFactory
Fixes #152
1 parent db36049 commit df6ff3c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

core/src/main/scala/scala/collection/parallel/ParIterableLike.scala

+10-2
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,11 @@ extends IterableOnce[T @uncheckedVariance]
550550
def apply() = shared
551551
def doesShareCombiners = true
552552
} else new CombinerFactory[T, Repr] {
553-
def apply() = newCombiner
553+
def apply() = {
554+
val r = newCombiner
555+
r.combinerTaskSupport = tasksupport
556+
r
557+
}
554558
def doesShareCombiners = false
555559
}
556560
}
@@ -563,7 +567,11 @@ extends IterableOnce[T @uncheckedVariance]
563567
def apply() = shared
564568
def doesShareCombiners = true
565569
} else new CombinerFactory[S, That] {
566-
def apply() = cbf()
570+
def apply() = {
571+
val r = cbf()
572+
r.combinerTaskSupport = tasksupport
573+
r
574+
}
567575
def doesShareCombiners = false
568576
}
569577
}

junit/src/test/scala/scala/collection/parallel/TaskTest.scala

+9
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,13 @@ class TaskTest {
3939

4040
for (x <- one ; y <- two) assertEquals("two", Thread.currentThread.getName)
4141
}
42+
43+
@Test
44+
def `t152 pass on task support`(): Unit = {
45+
val myTs = new ExecutionContextTaskSupport()
46+
val c = List(1).par
47+
c.tasksupport = myTs
48+
val r = c.filter(_ != 0).map(_ + 1)
49+
assertSame(myTs, r.tasksupport)
50+
}
4251
}

0 commit comments

Comments
 (0)