Skip to content

Commit

Permalink
Fix interrupting taking a cell completed while selecting with a defau…
Browse files Browse the repository at this point in the history
…lt clause
  • Loading branch information
adamw committed Aug 26, 2023
1 parent 52bdcf5 commit 875796b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/main/scala/ox/channels/select.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ private def doSelect[T](clauses: List[SelectClause[T]]): SelectResult[T] | Chann
case (ChannelClosed.Done, false) => DefaultResult(d.value)
case (e: ChannelClosed.Error, _) => e
case false => DefaultResult(d.value)
case true => takeFromCellInterruptSafe(c, Nil) // the cell hasn't been offered to any channel
case true =>
// the cell has been satisfied, it shouldn't yet be owned; owning it in case take() is interrupted
if !c.tryOwn() then throw IllegalStateException()
takeFromCellInterruptSafe(c, Nil) // the cell hasn't been offered to any channel

//

Expand Down

0 comments on commit 875796b

Please sign in to comment.