cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

Implement an optimized `Queue.synchronous` for `Async[F]`

Open djspiewak opened this issue 3 years ago • 0 comments
trafficstars

The new, optimized Queue implementation(s)(from #2885) don't support queues of size 0. The fact that the existing Concurrent versions do is actually kind of interesting and weird. In a lot of ways, Queue.synchronous is a very different data structure from Queue.bounded. It should be possible to implement it using a pair of queues, UnsafeUnbounded[(A, Right[Nothing, Unit] => Unit)] and UnsafeUnbounded[Right[Nothing, A] => Unit], but the race conditions on the double-check are very tricky. This is still probably worth doing though since synchronous is a commonly used primitive in a lot of cases.

djspiewak avatar Mar 19 '22 15:03 djspiewak