diff --git a/src/lock/api.rs b/src/lock/api.rs index 3b9b6b1618..e48be61b5a 100644 --- a/src/lock/api.rs +++ b/src/lock/api.rs @@ -11,7 +11,7 @@ use core::ops::{Deref, DerefMut}; // TODO: For weak memory, there needs to be a bit more stricter condition. unlock -hb→ lock. pub unsafe trait RawLock: Default + Send + Sync { /// Raw lock's token type. - type Token; + type Token: Send + Sync; /// Acquires the raw lock. fn lock(&self) -> Self::Token; diff --git a/src/lock/clhlock.rs b/src/lock/clhlock.rs index c85fb43dfb..9bf850be0a 100644 --- a/src/lock/clhlock.rs +++ b/src/lock/clhlock.rs @@ -12,6 +12,9 @@ struct Node { #[derive(Debug, Clone)] pub struct Token(*const CachePadded); +unsafe impl Send for Token {} +unsafe impl Sync for Token {} + /// CLH lock. #[derive(Debug)] pub struct ClhLock { diff --git a/src/lock/mcslock.rs b/src/lock/mcslock.rs index edae4fc164..d7c99916b7 100644 --- a/src/lock/mcslock.rs +++ b/src/lock/mcslock.rs @@ -14,6 +14,9 @@ struct Node { #[derive(Debug, Clone)] pub struct Token(*mut CachePadded); +unsafe impl Send for Token {} +unsafe impl Sync for Token {} + /// An MCS lock. #[derive(Debug)] pub struct McsLock { diff --git a/src/lock/mcsparkinglock.rs b/src/lock/mcsparkinglock.rs index 4aab2b931a..5e6dc67387 100644 --- a/src/lock/mcsparkinglock.rs +++ b/src/lock/mcsparkinglock.rs @@ -16,6 +16,9 @@ struct Node { #[derive(Debug, Clone)] pub struct Token(*mut CachePadded); +unsafe impl Send for Token {} +unsafe impl Sync for Token {} + /// An MCS parking lock. #[derive(Debug)] pub struct McsParkingLock {