From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/fd-lock/src/read_guard.rs | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 vendor/fd-lock/src/read_guard.rs (limited to 'vendor/fd-lock/src/read_guard.rs') diff --git a/vendor/fd-lock/src/read_guard.rs b/vendor/fd-lock/src/read_guard.rs new file mode 100644 index 000000000..29ed06da3 --- /dev/null +++ b/vendor/fd-lock/src/read_guard.rs @@ -0,0 +1,43 @@ +use std::ops; + +use crate::sys; + +/// RAII structure used to release the shared read access of a lock when +/// dropped. +/// +/// This structure is created by the [`read`] and [`try_read`] methods on +/// [`RwLock`]. +/// +/// [`read`]: crate::RwLock::read +/// [`try_read`]: crate::RwLock::try_read +/// [`RwLock`]: crate::RwLock +/// +/// # Panics +/// +/// Dropping this type may panic if the lock fails to unlock. +#[must_use = "if unused the RwLock will immediately unlock"] +#[derive(Debug)] +pub struct RwLockReadGuard<'lock, T: sys::AsRaw> { + guard: sys::RwLockReadGuard<'lock, T>, +} + +impl<'lock, T: sys::AsRaw> RwLockReadGuard<'lock, T> { + pub(crate) fn new(guard: sys::RwLockReadGuard<'lock, T>) -> Self { + Self { guard } + } +} + +impl ops::Deref for RwLockReadGuard<'_, T> { + type Target = T; + + #[inline] + fn deref(&self) -> &Self::Target { + self.guard.deref() + } +} + +/// Release the lock. +impl Drop for RwLockReadGuard<'_, T> { + #[inline] + fn drop(&mut self) {} +} -- cgit v1.2.3