-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make isempty(c::Channel)
a non-mutating operation
#36641
Conversation
Seems like arguably a bugfix. I would not think that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should also define this in terms of isempty
on the internal objects (O(1)) instead of length (O(n)), but this is a good fix regardless
I'm honestly not sure when this fallback is a good idea: Line 773 in 110765a
It seems a bad idea to me to ever call |
Previously, `isempty(c::Channel)` would fall back to `iterate(c) === nothing`, which actually consumed a value from the channel. Instead, let's just define it in terms of its internal datastructures.
cb4dd43
to
5ad48c7
Compare
We have very few iterators that are mutable, but they have a few extra requirements. We should probably document what those are ... or at least figure out what they are ;). |
That said, there is a bit of a problem with this kind of query in general, since |
I think that's the difference between |
I am quite sure we did not intend |
The usual method of applying verbs from other areas and seeing if they work; I had a close(c)
while !isempty(c)
process(take!(c))
end Which seemed to work, except then I noticed it was only processing every other item. I would be fine with defining |
I think the only thing that really works for that is something like |
Codecov Report
@@ Coverage Diff @@
## master #36641 +/- ##
=======================================
Coverage 86.15% 86.15%
=======================================
Files 349 349
Lines 65809 65809
=======================================
Hits 56698 56698
Misses 9111 9111 Continue to review full report at Codecov.
|
Previously, `isempty(c::Channel)` would fall back to `iterate(c) === nothing`, which actually consumed a value from the channel. Instead, let's just define it in terms of its internal datastructures. (cherry picked from commit 4481500)
Previously, `isempty(c::Channel)` would fall back to `iterate(c) === nothing`, which actually consumed a value from the channel. Instead, let's just define it in terms of its internal datastructures.
Previously,
isempty(c::Channel)
would fall back toiterate(c) === nothing
, which actually consumed a value from the channel. Instead,let's just define it in terms of
isready(c)
since that already exists.