Skip to content

Commit

Permalink
Fixed send and sync for mutex and rwlock
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang2014 committed Sep 2, 2021
1 parent cbd8a3c commit 26028ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions common/infallible/src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ use parking_lot::MutexGuard;
#[derive(Debug)]
pub struct Mutex<T>(ParkingMutex<T>);

/// Mutex is Send
unsafe impl<T> Send for Mutex<T> {}

/// Mutex is Sync
unsafe impl<T> Sync for Mutex<T> {}
unsafe impl<T> Send for Mutex<T> where ParkingMutex<T>: Send {}
unsafe impl<T> Sync for Mutex<T> where ParkingMutex<T>: Sync {}

impl<T> Mutex<T> {
/// creates mutex
Expand Down
4 changes: 2 additions & 2 deletions common/infallible/src/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use parking_lot::RwLockWriteGuard;
#[derive(Debug, Default)]
pub struct RwLock<T>(ParkingRwLock<T>);

unsafe impl<T> Send for RwLock<T> {}
unsafe impl<T> Sync for RwLock<T> {}
unsafe impl<T> Send for RwLock<T> where ParkingRwLock<T>: Send {}
unsafe impl<T> Sync for RwLock<T> where ParkingRwLock<T>: Sync {}

impl<T> RwLock<T> {
/// creates a read-write lock
Expand Down

0 comments on commit 26028ef

Please sign in to comment.