3 ms·
> availableToPoll() is the method that blocks, because it can return 0 on an empty ring. Which means it doesn't block... Blocking means the call itself doesn'
by kllrnohj 2y ago
> availableToPoll() is the method that blocks, because it can return 0 on an empty ring.
Which means it doesn't block...
Blocking means the call itself doesn't return until there's data available. This is a completely non-blocking API. Which is fine, it's just very wrongly named in that case.
But that also means I don't really know why there's both "non-blocking" and "blocking" variants at that point if blocking isn't an option at all in the first place.
- joas_coder 2y agoYou are going to block/wait yourself when availableToPoll() (now changed to availableToFetch() for clarity) returns 0. When that happens you can block/wait by busy spinning or by using a wait strategy. The blocking term means that the producer has to block/wait when the ring is full and the consumer has to block/wait when the ring is empty. For the non-blocking ring, the producer never blocks on a full ring. It overwrites the circular ring. The consumer can still block on an empty ring. So to make it clear: Blocking ring => producer and consumer can block/wait Non-Blocking ring => producer never blocks and consumer can still block on an empty ring. Consumer can also fall behind too much and disconnect.