Skip to content

Commit

Permalink
Fix deadlock on Channel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
natsukagami committed May 8, 2024
1 parent e3afefd commit 5f95a56
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions shared/src/main/scala/async/channels.scala
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ object Channel:
* there are *only* all readers or all senders. It must be externally synchronized.
*/
private[async] class CellBuf():
case class Send(cs: CanSend, sender: Sender^)
final case class Send(cs: CanSend, sender: Sender^)
type Cell = Reader | Send
// reader == 0 || sender == 0 always
private var reader = 0
Expand All @@ -293,7 +293,8 @@ object Channel:
pending.head.asInstanceOf[Reader]
def nextSender =
require(sender > 0)
pending.head.asInstanceOf[(CanSend, Sender)]
val Send(cs, s) = pending.head.asInstanceOf[Send]
(cs, s)
def dequeue() =
pending.dequeue()
if reader > 0 then reader -= 1 else sender -= 1
Expand Down

0 comments on commit 5f95a56

Please sign in to comment.