Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add a method on Receiver that gives information on queue status in broadcast channel #4542
Add a method on Receiver that gives information on queue status in broadcast channel #4542
Changes from 1 commit
b36ce25
841963f
bb10d77
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Is
num_msgs
the right name for this function?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'm not sure, but I think it's clearer than
len
(which is mostly used for container like data structures). Plus clippy complained that this missed anempty
method given that it had alen
method, where again I'm not sure it makes sense to speak of aReceiver
as being empty, though some people might like that interface.num_msgs
is probably not great either, I was thinking of something likenum_queued_messages
, but thought it might have been too verbose. I'm open to choose whatever you think is the most plausible choice.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 posted this question for discussion on
#tokio-dev
on discord.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 would be inclined to just call this
len
---crossbeam::channel
has alen
method, and I think the meaning of referring to a channel's "length" is relatively unambiguous. Alternatively, if we don't want to call it a "length", i would suggestnum_queued
--- I don't think adding "messages" to the method name conveys as much information...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.
Is
u64
the right return type here? Theusize
type seems more reasonable to me.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 chose that because
tail.pos
has that type.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.
On the other hand, the capacity argument to the constructor for the channel takes an
usize
.(The reason that
tail.pos
has the typeu64
is that it needs to fit the total number of messages that will be sent on the channel, not just the total number of messages in-flight at any one time.)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.
It should be
usize
.