devices: queue: Keep clone of mem instead of Rc

GuestMemory is just Arcs, cloning it is as cheap as keeping an Rc.

Change-Id: I160585ce0cf70aa0ec33897b550b82fe09bde2a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2364992
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
This commit is contained in:
Dylan Reid 2020-08-18 14:47:59 -07:00 committed by Commit Bot
parent 2e8f355ba0
commit 7ca98fb599

View file

@ -505,13 +505,13 @@ impl Queue {
/// re-enabled on drop.
pub struct NotifyGuard {
queue: Rc<RefCell<Queue>>,
mem: Rc<GuestMemory>,
mem: GuestMemory,
}
impl NotifyGuard {
/// Disable notifications for the lifetime of the returned guard. Useful when the caller is
/// processing a descriptor and doesn't need notifications of further messages from the guest.
pub fn new(queue: Rc<RefCell<Queue>>, mem: Rc<GuestMemory>) -> Self {
pub fn new(queue: Rc<RefCell<Queue>>, mem: GuestMemory) -> Self {
// Disable notification until we're done processing the next request.
queue.borrow_mut().set_notify(&mem, false);
NotifyGuard { queue, mem }