diff options
author | Zach Reizner <zachr@google.com> | 2019-07-23 15:55:03 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-07-24 06:07:20 +0000 |
commit | b2110bef59d72529d99c722df9b3e9a1d705e6f4 (patch) | |
tree | e69899bce04e4ade12a33121b84517ee886216f2 /devices/src/virtio/input/mod.rs | |
parent | 229063c2bf2ee365458c8fd5cdda2ab27a23bf98 (diff) | |
download | crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.gz crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.bz2 crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.lz crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.xz crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.tar.zst crosvm-b2110bef59d72529d99c722df9b3e9a1d705e6f4.zip |
tree-wide: use PollContext::build_with where possible
The old method of creating a PollContext and calling `add` inside of `and_then` chains was an ugly way handle the Results that can crop up after each call. The `build_with` function is equivalent but operates on a slice which has way less boilerplate. TEST=./build_test BUG=None Change-Id: I8b0d6532680e04c501187397bd211014a2363c25 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1715581 Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'devices/src/virtio/input/mod.rs')
-rw-r--r-- | devices/src/virtio/input/mod.rs | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/devices/src/virtio/input/mod.rs b/devices/src/virtio/input/mod.rs index 195a2e0..3bed5ef 100644 --- a/devices/src/virtio/input/mod.rs +++ b/devices/src/virtio/input/mod.rs @@ -566,25 +566,13 @@ impl<T: EventSource> Worker<T> { InterruptResample, Kill, } - let poll_ctx: PollContext<Token> = match PollContext::new() - .and_then(|pc| { - pc.add(&event_queue_evt_fd, Token::EventQAvailable) - .and(Ok(pc)) - }) - .and_then(|pc| { - pc.add(&status_queue_evt_fd, Token::StatusQAvailable) - .and(Ok(pc)) - }) - .and_then(|pc| { - pc.add(&self.event_source, Token::InputEventsAvailable) - .and(Ok(pc)) - }) - .and_then(|pc| { - pc.add(&self.interrupt_resample_evt, Token::InterruptResample) - .and(Ok(pc)) - }) - .and_then(|pc| pc.add(&kill_evt, Token::Kill).and(Ok(pc))) - { + let poll_ctx: PollContext<Token> = match PollContext::build_with(&[ + (&event_queue_evt_fd, Token::EventQAvailable), + (&status_queue_evt_fd, Token::StatusQAvailable), + (&self.event_source, Token::InputEventsAvailable), + (&self.interrupt_resample_evt, Token::InterruptResample), + (&kill_evt, Token::Kill), + ]) { Ok(poll_ctx) => poll_ctx, Err(e) => { error!("failed creating PollContext: {}", e); |