You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At some specific points in my code, I need to know if a ChannelReader is empty.
Thanks to this issue: #26706
Followed by this PR; https://github.com/dotnet/runtime/pull/312/files
I was able, since .Net 5, to use Count for this purpose.
My code is mostly focused on UnboundedChannelReaders, and everything
was going really well, being able to get the expected benefits from using this property.
I started having troubles when using an Unbounded channel with a single reader.
SingleConsumerUnboundedChannel is "backed" by a SingleProducerSingleConsumerQueue and using Count is not possible,
leading to some exceptions.
This limitation is normal, as explained here: #44928
This is an issue for me, as it makes me handle two differents path in my code, based on the number of readers.
Or simply constrains me not to use the "SingleReader " property of UnboundedChannelOptions.
My initial need was not a "Count" property, but rather a "IsEmpty" property, perfectly exposed in the SingleProducerSingleConsumerQueue.
So, If it was agreed to expose a .{Can}Count property on ChannelReader, could it be possible to do the same with
the IsEmpty property ?
As for the initial PR made by mgravell for Count , I know the information is only true at some specific points, with real "race condition" related issues.
But at some really specific occasions it is really helpfull to know if "there is something" in my workflow, and the "Count" property, no matter how "overkill" it is for my need, already makes a great difference.
Having the right property, and having it for any implementation of the ChanneReader, could really help.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
At some specific points in my code, I need to know if a ChannelReader is empty.
Thanks to this issue:
#26706
Followed by this PR;
https://github.com/dotnet/runtime/pull/312/files
I was able, since .Net 5, to use Count for this purpose.
My code is mostly focused on UnboundedChannelReaders, and everything
was going really well, being able to get the expected benefits from using this property.
I started having troubles when using an Unbounded channel with a single reader.
SingleConsumerUnboundedChannel is "backed" by a SingleProducerSingleConsumerQueue and using Count is not possible,
leading to some exceptions.
This limitation is normal, as explained here:
#44928
This is an issue for me, as it makes me handle two differents path in my code, based on the number of readers.
Or simply constrains me not to use the "SingleReader " property of UnboundedChannelOptions.
My initial need was not a "Count" property, but rather a "IsEmpty" property, perfectly exposed in the SingleProducerSingleConsumerQueue.
So, If it was agreed to expose a .{Can}Count property on ChannelReader, could it be possible to do the same with
the IsEmpty property ?
As for the initial PR made by mgravell for Count , I know the information is only true at some specific points, with real "race condition" related issues.
But at some really specific occasions it is really helpfull to know if "there is something" in my workflow, and the "Count" property, no matter how "overkill" it is for my need, already makes a great difference.
Having the right property, and having it for any implementation of the ChanneReader, could really help.
Beta Was this translation helpful? Give feedback.
All reactions