From: "tip-bot2 for Lyude Paul" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Lyude Paul <lyude@redhat.com>, Alice Ryhl <aliceryhl@google.com>,
Boqun Feng <boqun.feng@gmail.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: locking/core] rust: sync: Add MutexGuard type alias
Date: Tue, 24 Dec 2024 18:53:41 -0000 [thread overview]
Message-ID: <173506642113.399.14882143596480911485.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20241120222742.2490495-2-lyude@redhat.com>
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 37624dde4768ec25d2f9798aa75bf32e18c0eae2
Gitweb: https://git.kernel.org/tip/37624dde4768ec25d2f9798aa75bf32e18c0eae2
Author: Lyude Paul <lyude@redhat.com>
AuthorDate: Wed, 20 Nov 2024 17:26:28 -05:00
Committer: Boqun Feng <boqun.feng@gmail.com>
CommitterDate: Thu, 19 Dec 2024 14:04:42 -08:00
rust: sync: Add MutexGuard type alias
A simple helper alias for code that needs to deal with Guard types returned
from Mutexes.
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20241120222742.2490495-2-lyude@redhat.com
---
rust/kernel/sync.rs | 2 +-
rust/kernel/sync/lock/mutex.rs | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
index 1eab7eb..2721b5c 100644
--- a/rust/kernel/sync.rs
+++ b/rust/kernel/sync.rs
@@ -16,7 +16,7 @@ pub mod poll;
pub use arc::{Arc, ArcBorrow, UniqueArc};
pub use condvar::{new_condvar, CondVar, CondVarTimeoutResult};
pub use lock::global::{global_lock, GlobalGuard, GlobalLock, GlobalLockBackend, GlobalLockedBy};
-pub use lock::mutex::{new_mutex, Mutex};
+pub use lock::mutex::{new_mutex, Mutex, MutexGuard};
pub use lock::spinlock::{new_spinlock, SpinLock};
pub use locked_by::LockedBy;
diff --git a/rust/kernel/sync/lock/mutex.rs b/rust/kernel/sync/lock/mutex.rs
index 0e946eb..10a70c0 100644
--- a/rust/kernel/sync/lock/mutex.rs
+++ b/rust/kernel/sync/lock/mutex.rs
@@ -86,6 +86,14 @@ pub use new_mutex;
/// [`struct mutex`]: srctree/include/linux/mutex.h
pub type Mutex<T> = super::Lock<T, MutexBackend>;
+/// A [`Guard`] acquired from locking a [`Mutex`].
+///
+/// This is simply a type alias for a [`Guard`] returned from locking a [`Mutex`]. It will unlock
+/// the [`Mutex`] upon being dropped.
+///
+/// [`Guard`]: super::Guard
+pub type MutexGuard<'a, T> = super::Guard<'a, T, MutexBackend>;
+
/// A kernel `struct mutex` lock backend.
pub struct MutexBackend;
next prev parent reply other threads:[~2024-12-24 18:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 22:26 [PATCH 0/2] rust: sync: Add Guard related type-aliases Lyude Paul
2024-11-20 22:26 ` [PATCH 1/2] rust: sync: Add MutexGuard type alias Lyude Paul
2024-11-25 9:47 ` Alice Ryhl
2024-12-24 18:53 ` tip-bot2 for Lyude Paul [this message]
2024-11-20 22:26 ` [PATCH 2/2] rust: sync: Add SpinLockGuard " Lyude Paul
2024-11-25 9:47 ` Alice Ryhl
2024-12-24 18:53 ` [tip: locking/core] " tip-bot2 for Lyude Paul
2024-11-27 18:22 ` [PATCH 0/2] rust: sync: Add Guard related type-aliases Boqun Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=173506642113.399.14882143596480911485.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=aliceryhl@google.com \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®