From 26028ef777b5a7335a83f8475bea0ddb7114ab13 Mon Sep 17 00:00:00 2001 From: zhang2014 Date: Thu, 2 Sep 2021 23:10:20 +0800 Subject: [PATCH] Fixed send and sync for mutex and rwlock --- common/infallible/src/mutex.rs | 7 ++----- common/infallible/src/rwlock.rs | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/common/infallible/src/mutex.rs b/common/infallible/src/mutex.rs index 8e7a7355b378d..a3f28431c0065 100644 --- a/common/infallible/src/mutex.rs +++ b/common/infallible/src/mutex.rs @@ -19,11 +19,8 @@ use parking_lot::MutexGuard; #[derive(Debug)] pub struct Mutex(ParkingMutex); -/// Mutex is Send -unsafe impl Send for Mutex {} - -/// Mutex is Sync -unsafe impl Sync for Mutex {} +unsafe impl Send for Mutex where ParkingMutex: Send {} +unsafe impl Sync for Mutex where ParkingMutex: Sync {} impl Mutex { /// creates mutex diff --git a/common/infallible/src/rwlock.rs b/common/infallible/src/rwlock.rs index 00c538229bcb2..c71609ad90944 100644 --- a/common/infallible/src/rwlock.rs +++ b/common/infallible/src/rwlock.rs @@ -21,8 +21,8 @@ use parking_lot::RwLockWriteGuard; #[derive(Debug, Default)] pub struct RwLock(ParkingRwLock); -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} +unsafe impl Send for RwLock where ParkingRwLock: Send {} +unsafe impl Sync for RwLock where ParkingRwLock: Sync {} impl RwLock { /// creates a read-write lock