-
Notifications
You must be signed in to change notification settings - Fork 89
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
Improve the usability of queue interfaces #148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,7 +155,9 @@ pub trait QueueStateT: for<'a> QueueStateGuard<'a> { | |
fn set_event_idx(&mut self, enabled: bool); | ||
|
||
/// Read the `idx` field from the available ring. | ||
fn avail_idx<M: GuestMemory>(&self, mem: &M, order: Ordering) -> Result<Wrapping<u16>, Error>; | ||
fn avail_idx<M>(&self, mem: &M, order: Ordering) -> Result<Wrapping<u16>, Error> | ||
where | ||
M: GuestMemory + ?Sized; | ||
|
||
/// Read the `idx` field from the used ring. | ||
fn used_idx<M: GuestMemory>(&self, mem: &M, order: Ordering) -> Result<Wrapping<u16>, Error>; | ||
|
@@ -193,4 +195,31 @@ pub trait QueueStateT: for<'a> QueueStateGuard<'a> { | |
|
||
/// Set the index for the next descriptor in the used ring. | ||
fn set_next_used(&mut self, next_used: u16); | ||
|
||
/// Pop and return the next available descriptor chain, or `None` when there are no more | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add some description about how this is suppose to be used (i.e. in respect to the already existing iterator; i think you mention this is an alternative way of consuming the iterator)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added an extra phrase to the comment. Didn't mention the iterator, as it doesn't even exist strictly in the context of the |
||
/// descriptor chains available. | ||
/// | ||
/// This enables the consumption of available descriptor chains in a "one at a time" | ||
/// manner, without having to hold a borrow after the method returns. | ||
fn pop_descriptor_chain<M>(&mut self, mem: M) -> Option<DescriptorChain<M>> | ||
where | ||
M: Clone + Deref, | ||
M::Target: GuestMemory; | ||
} | ||
|
||
/// Trait to access and manipulate a Virtio queue that's known to be exclusively accessed | ||
/// by a single execution thread. | ||
pub trait QueueStateOwnedT: QueueStateT { | ||
/// Get a consuming iterator over all available descriptor chain heads offered by the driver. | ||
/// | ||
/// # Arguments | ||
/// * `mem` - the `GuestMemory` object that can be used to access the queue buffers. | ||
fn iter<M>(&mut self, mem: M) -> Result<AvailIter<'_, M>, Error> | ||
where | ||
M: Deref, | ||
M::Target: GuestMemory; | ||
|
||
/// Undo the last advancement of the next available index field by decrementing its | ||
/// value by one. | ||
fn go_to_previous_position(&mut self); | ||
jiangliu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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.
Can you add a description about this in the commit message as well? It will help with writing the changelog.
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.
Hmm, I think it's better to relax the trait bounds for the other methods as well first via a separate PR, and add that to the changelog. Created #152 to track this.
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 this change required in this commit? If not, I would postpone it when fixing #152, if yes, I would still leave some sort of explanation about it in the commit message or at least give a pointer to #152.
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.
Added an explanation, and mentioned the issue as well in the commit message.