mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2026-01-04 16:38:03 +00:00
video: don't needlessly clone Waker
Clippy complains about Option::take() called on a temporary value:
```text
error: called `Option::take()` on a temporary value
--> vhost-device-video/src/stream.rs:125:30
|
125 | if let Some(waker) = self.waker().take() {
| ^^^^^^^^^^^^^^^^^^^
|
= note: `waker` creates a temporary value, so calling take() has no effect
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_take
= note: `-D clippy::needless-option-take` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_option_take)]`
```
But Waker is meant to be consumed when calling Waker::wake, so there's
no need to clone temporary values. Move the .wake() call inside
ResourceState's set_ready() method so we don't have to lock the mutex
again.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
parent
710e651af2
commit
2012d2198b
@ -63,6 +63,9 @@ impl SharedResourceState {
|
||||
|
||||
pub fn set_ready(&mut self) {
|
||||
self.set_state(ResourceState::Ready);
|
||||
if let Some(waker) = self.waker.take() {
|
||||
waker.wake();
|
||||
}
|
||||
}
|
||||
|
||||
fn set_state(&mut self, state: ResourceState) {
|
||||
@ -122,9 +125,6 @@ impl Resource {
|
||||
|
||||
pub fn set_ready(&mut self) {
|
||||
self.state.write().unwrap().set_ready();
|
||||
if let Some(waker) = self.waker().take() {
|
||||
waker.wake();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_ready(&self) -> bool {
|
||||
@ -138,10 +138,6 @@ impl Resource {
|
||||
pub fn set_queued(&mut self) {
|
||||
self.state.write().unwrap().set_queued();
|
||||
}
|
||||
|
||||
pub fn waker(&self) -> Option<Waker> {
|
||||
self.state.read().unwrap().waker.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user