Description
Description
The SingleConsumerUnboundedChannel
currently does not allow accessing the item count. This is strange because if you have multiple consumers via UnboundedChannel
the access is possible. It feels like a bug to me that you cannot access the count if you have a single consumer but you can if you have multiple ones.
Configuration
.net 5.0.203
Windows 10 Enterprise 2004
x64
Also seems an issue according to the latest source state.
Regression?
From a pure code perspective no. This was never implemented and is sort of a missing feature.
Other information
Code wise it should be fairly easy to add the same count implementation to SingleConsumerUnboundedChannel
like in UnboundedChannel
.
UnboundedChannel overrides the count and cancount in the reader implementation
SingleConsumerUnboundedChannel does not override the members
But I have to admit that I am not fully aware of potential consequences. There were some concerns by @stephentoub because of the queue not being secured by locks or interlocked operations. The UnboundedChannel uses a Deque which holds the current size as member. So accessing the size is safe. But the SingleConsumerUnboundedChannel
uses a SingleProducerConsumerQueue
where the count it only internal and requires looping.
From this perspective it might really rather be a feature request than a bug to support the count.
According to the git history the following PR and issue are related to the change adding the count member to UnboundedChannel.
#312
#26706