summary refs log tree commit diff
path: root/sys_util/src/eventfd.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2017-05-24 20:09:22 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-06-30 12:51:24 -0700
commita053a28685bd87a4b7a92f9e72b6ac214008e001 (patch)
tree35f568b3fa9b7b7499821b654bd279b1d88640f0 /sys_util/src/eventfd.rs
parent79b2a732729219e2b4b0bc5ef8ab3ac23f28e562 (diff)
downloadcrosvm-a053a28685bd87a4b7a92f9e72b6ac214008e001.tar
crosvm-a053a28685bd87a4b7a92f9e72b6ac214008e001.tar.gz
crosvm-a053a28685bd87a4b7a92f9e72b6ac214008e001.tar.bz2
crosvm-a053a28685bd87a4b7a92f9e72b6ac214008e001.tar.lz
crosvm-a053a28685bd87a4b7a92f9e72b6ac214008e001.tar.xz
crosvm-a053a28685bd87a4b7a92f9e72b6ac214008e001.tar.zst
crosvm-a053a28685bd87a4b7a92f9e72b6ac214008e001.zip
src_util: add poll module
The poll module adds the Poller object for waiting on mutliple file
descriptors at once. The Pollable trait is introduced so rust objects
can expose a file descriptor useful for polling. An impl for EventFd is
included with this change for testing.

TEST=cargo test
BUG=None

Change-Id: I94fd15a17fe0527c0d29c623badb90668d708689
Reviewed-on: https://chromium-review.googlesource.com/514413
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'sys_util/src/eventfd.rs')
-rw-r--r--sys_util/src/eventfd.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys_util/src/eventfd.rs b/sys_util/src/eventfd.rs
index 0540b5d..9298a05 100644
--- a/sys_util/src/eventfd.rs
+++ b/sys_util/src/eventfd.rs
@@ -83,6 +83,12 @@ impl AsRawFd for EventFd {
     }
 }
 
+unsafe impl ::Pollable for EventFd {
+    fn pollable_fd(&self) -> RawFd {
+        self.eventfd.as_raw_fd()
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;