Reputation: 9540
There is TPriorityQueue
in ZIO which is unbounded. Is there a way to adapt it to become bounded?
Upvotes: 1
Views: 201
Reputation: 7706
If you don't care about performance too much you can do something quick and dirty like this:
case class TPW(tpq: TPriorityQueue[Int]) {
def offer(e: Int) = ZSTM.whenM(tpq.size.map(_ < 50))(tpq.offer(e))
// .. other methods
}
This would be a dropping queue.
Upvotes: 1