Skip to content

Commit

Permalink
Merge pull request #271 from Atry/fork-fix
Browse files Browse the repository at this point in the history
Add synchronized block for mutable builders
  • Loading branch information
Atry authored Jun 21, 2019
2 parents 2320db2 + b7a3835 commit 4e2e1d8
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,19 @@ object Fork {
val element = !ForEach(fork.elements)
counter.incrementAndGet()
try {
builder ++= !Shift(mapper(element));
()
val result = !Shift(mapper(element))
builder.synchronized[Unit] {
builder ++= result
}
} catch {
case MultipleException(throwableSet) =>
exceptionBuilder ++= throwableSet;
()
exceptionBuilder.synchronized[Unit] {
exceptionBuilder ++= throwableSet
}
case e: Throwable =>
exceptionBuilder += e;
()
exceptionBuilder.synchronized[Unit] {
exceptionBuilder += e
}
} finally {
if (counter.decrementAndGet() > 0) {
!Continue
Expand Down

0 comments on commit 4e2e1d8

Please sign in to comment.