Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions kyo-core/shared/src/main/scala/kyo/Queue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,13 @@ object Queue:
offerOp(
q.offer(v),
q.poll() match
case Maybe.Present(polled) => !(polled.asInstanceOf[AnyRef] eq v.asInstanceOf[AnyRef])
case _ => true
case Maybe.Present(polled) =>
val isOurs = polled.asInstanceOf[AnyRef] eq v.asInstanceOf[AnyRef]
if !isOurs then
// Polled someone else's element — put it back
discard(q.offer(polled))
!isOurs
case _ => true
)
def poll()(using AllowUnsafe) = pollOp(q.poll())
def peek()(using AllowUnsafe) = op(q.peek())
Expand Down
4 changes: 2 additions & 2 deletions kyo-core/shared/src/test/scala/kyo/ChannelTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ class ChannelTest extends Test:
.andThen(succeed)
}

"offer and poll" in runNotNative {
"offer and poll" in run {
(for
size <- Choice.eval(0, 1, 2, 10, 100)
channel <- Channel.init[Int](size)
Expand All @@ -657,7 +657,7 @@ class ChannelTest extends Test:
.andThen(succeed)
}

"put and take" in runNotNative {
"put and take" in run {
(for
size <- Choice.eval(0, 1, 2, 10, 100)
channel <- Channel.init[Int](size)
Expand Down
Loading