Skip to content

Commit fc8cc48

Browse files
committed
Make Registration Send as well.
1 parent 263d0bc commit fc8cc48

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rust/kernel/miscdev.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ impl<T: Sync> Registration<T> {
8080

8181
// SAFETY: The only method is `register()`, which requires a (pinned) mutable `Registration`, so it
8282
// is safe to pass `&Registration` to multiple threads because it offers no interior mutability,
83-
// except maybe through [`Registration::context`], but it is itself [`Sync`].
83+
// except maybe through `Registration::context`, but it is itself `Sync`.
8484
unsafe impl<T: Sync> Sync for Registration<T> {}
8585

86+
// SAFETY: All functions work from any thread. So as long as the `Registration::context` is
87+
// `Send`, so is `Registration<T>`. `T` needs to be `Sync` because it's a requirement of
88+
// `Registration<T>`.
89+
unsafe impl<T: Send + Sync> Send for Registration<T> {}
90+
8691
impl<T: Sync> Drop for Registration<T> {
8792
/// Removes the registration from the kernel if it has completed successfully before.
8893
fn drop(&mut self) {

0 commit comments

Comments
 (0)