yruslan / channel_scala

Scala implementation of the concurrency primitive similar to GoLang channels.
Apache License 2.0
8 stars 0 forks source link

Filtering a channel foes not filter out some elements at random #20

Closed yruslan closed 10 months ago

yruslan commented 10 months ago

Describe the bug

Here is an example unit test:

val ch1 = Channel.make[Int](3)

val ch2 = ch1.filter(v => v == 3)

ch1.send(1)
ch1.send(2)

val v1 = ch2.tryRecv(timeout)
ch1.close()

assert(v1.isEmpty)

The error is:

Some(2) does not equal to None.

Expected behavior

Since the predicate is v == 3, the value 2 should have been skipped.