rust: sync: introduce LockedBy
This allows us to have data protected by a lock despite not being wrapped by it. Access is granted by providing evidence that the lock is held by the caller. Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com> Reviewed-by: Benno Lossin <benno.lossin@proton.me> Link: https://lore.kernel.org/r/20230411054543.21278-13-wedsonaf@gmail.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
committed by
Miguel Ojeda
parent
8da7a2b743
commit
7b1f55e3a9
@@ -74,7 +74,7 @@ pub struct Lock<T: ?Sized, B: Backend> {
|
||||
_pin: PhantomPinned,
|
||||
|
||||
/// The data protected by the lock.
|
||||
data: UnsafeCell<T>,
|
||||
pub(crate) data: UnsafeCell<T>,
|
||||
}
|
||||
|
||||
// SAFETY: `Lock` can be transferred across thread boundaries iff the data it protects can.
|
||||
|
||||
Reference in New Issue
Block a user