3 ms·
A ring buffer has a limit to the number of unread items before you either block or start discarding. Different use cases I suppose.
by daigoba66 10y ago
A ring buffer has a limit to the number of unread items before you either block or start discarding. Different use cases I suppose.
- adrianratnapala 10y agoI think the fixed-size limitation is the least important thing in practice. If your queue is filling up arbitrarily far, then you are almost certainly in trouble anyway, and want some limitation strategy. The ring buffer gives you this quite naturally. I suppose there could be cases where you did not want to pre-commit to a buffer size. E.g. you have lots of queues which you expect to be short, but which might grow large in rare cases. But I have never actually seen such a case.
- ramchip 10y agoI would expect it to be a common use case in actor-based systems like Erlang, Akka, etc. It's perfectly supported to have 100k+ processes running in an Erlang VM, but the vast majority of them will have an empty message queue at any given time.
- adrianratnapala 10y agoIndeed large numbers of small queues are an important case. But large numbers of small queues, every one of which might unexpectedly but legitimately need to grow large is not. I don't know Erlang or Akka first hand, but I know that Go channels are inpsired by Erlang. Channels can be very numerous and are usually empty; but they are fixed size. In the rare occasion that you think a channel needs more buffering, you must say so explicilty.