Skip to content

Commit

Permalink
Merge pull request scala#7940 from retronym/topic/batching-executor
Browse files Browse the repository at this point in the history
Don't clear parent block context of AsyncBatch
  • Loading branch information
adriaanm authored Mar 28, 2019
2 parents 08b9e8b + 710bb4d commit 59975bb
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/library/scala/concurrent/BatchingExecutor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,17 @@ private[concurrent] trait BatchingExecutor extends Executor {
private[this] final def cloneAndClear(): AsyncBatch = {
val newBatch = new AsyncBatch(this.first, this.other, this.size)
this.first = null
this.parentBlockContext = BatchingExecutorStatics.MissingParentBlockContext
this.other = BatchingExecutorStatics.emptyBatchArray
this.size = 0
newBatch
}

override final def blockOn[T](thunk: => T)(implicit permission: CanAwait): T = {
val pbc = parentBlockContext // Store this for later since `cloneAndClear()` will reset it

// If we know there will be blocking, we don't want to keep tasks queued up because it could deadlock.
if(this.size > 0)
submitForExecution(cloneAndClear()) // If this throws then we have bigger problems

pbc.blockOn(thunk) // Now delegate the blocking to the previous BC
parentBlockContext.blockOn(thunk) // Now delegate the blocking to the previous BC
}
}

Expand Down

0 comments on commit 59975bb

Please sign in to comment.