From 6c0fdb05e9471596a93b1fbb7c9897aea638396a Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Mon, 19 Apr 2021 20:44:45 +0200 Subject: [PATCH] Make device clonable --- src/device.rs | 9 +++++++++ src/lib.rs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/device.rs b/src/device.rs index 4ff455e..7c1d394 100644 --- a/src/device.rs +++ b/src/device.rs @@ -36,6 +36,15 @@ pub struct Device { ffi: Ptr<::ffi::gbm_device>, } +impl Clone for Device { + fn clone(&self) -> Device { + Device { + fd: self.fd.clone(), + ffi: self.ffi.clone(), + } + } +} + unsafe impl Send for Ptr<::ffi::gbm_device> {} impl AsRawFd for Device { diff --git a/src/lib.rs b/src/lib.rs index d53cccc..40c9bf7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -129,6 +129,7 @@ impl Drop for PtrDrop { } } +#[derive(Clone)] pub(crate) struct Ptr(Arc>); impl Ptr { @@ -180,4 +181,4 @@ mod test { fn unmapped_bo_is_send() { is_send::>(); } -} \ No newline at end of file +}