Skip to content

Commit 95578bf

Browse files
committed
Add Send/Sync to token, needed for LockGuard Send/Sync impl.
1 parent 2287e7a commit 95578bf

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/lock/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use core::ops::{Deref, DerefMut};
1111
// TODO: For weak memory, there needs to be a bit more stricter condition. unlock -hb→ lock.
1212
pub unsafe trait RawLock: Default + Send + Sync {
1313
/// Raw lock's token type.
14-
type Token;
14+
type Token: Send + Sync;
1515

1616
/// Acquires the raw lock.
1717
fn lock(&self) -> Self::Token;

src/lock/clhlock.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ struct Node {
1212
#[derive(Debug, Clone)]
1313
pub struct Token(*const CachePadded<Node>);
1414

15+
unsafe impl Send for Token {}
16+
unsafe impl Sync for Token {}
17+
1518
/// CLH lock.
1619
#[derive(Debug)]
1720
pub struct ClhLock {

src/lock/mcslock.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ struct Node {
1414
#[derive(Debug, Clone)]
1515
pub struct Token(*mut CachePadded<Node>);
1616

17+
unsafe impl Send for Token {}
18+
unsafe impl Sync for Token {}
19+
1720
/// An MCS lock.
1821
#[derive(Debug)]
1922
pub struct McsLock {

src/lock/mcsparkinglock.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ struct Node {
1616
#[derive(Debug, Clone)]
1717
pub struct Token(*mut CachePadded<Node>);
1818

19+
unsafe impl Send for Token {}
20+
unsafe impl Sync for Token {}
21+
1922
/// An MCS parking lock.
2023
#[derive(Debug)]
2124
pub struct McsParkingLock {

0 commit comments

Comments
 (0)