Skip to contentSkip to conversation

revl: Mutex shouldn't require locked objects to have the Sync trait

PATCH Applied Jussi Viiri 2 participants 2 messages Aug 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 revl: Mutex shouldn't require locked objects to have the Sync trait

As said in the title, Mutex shouldn't require locked objects to have the Sync trait. The point of the Mutex object is to provide that trait by wrapping an object. Used ?Sized + Send like std::sync::Mutex instead.

---

From 04c362a8239a71a516fb7405e3720d4cf25951dd Mon Sep 17 00:00:00 2001
From: Jussi Viiri <[email protected]>
Date: Fri, 26 Aug 2022 10:29:04 +0300
Subject: [PATCH 4/4] Mutex shouldn't require locked objects to have the Sync trait

---
 src/mutex.rs | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
src/mutex.rs +0 -0
index 57e1670..af58d40 100644
@@ -139,8 +139,8 @@ pub struct Mutex<T: ?Sized> {

     data: UnsafeCell<T>,
 }

-unsafe impl<T: Sync + Send> Send for Mutex<T> {} -unsafe impl<T: Sync + Send> Sync for Mutex<T> {} +unsafe impl<T: ?Sized + Send> Send for Mutex<T> {} +unsafe impl<T: ?Sized + Send> Sync for Mutex<T> {}

 impl<T> Mutex<T> {
     /// Create a new mutex for guarding data, using the properties

Signature · 1 line
2.25.1
#1 lore raw
Quoted 24 lines · Jussi Viiri

As said in the title, Mutex shouldn't require locked objects to have the Sync trait. The point of the Mutex object is to provide that trait by wrapping an object.
Used ?Sized + Send like std::sync::Mutex instead.

---

From 04c362a8239a71a516fb7405e3720d4cf25951dd Mon Sep 17 00:00:00 2001
From: Jussi Viiri <[email protected]>
Date: Fri, 26 Aug 2022 10:29:04 +0300
Subject: [PATCH 4/4] Mutex shouldn't require locked objects to have the Sync trait

---
 src/mutex.rs | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
src/mutex.rs +0 -0
index 57e1670..af58d40 100644

src/mutex.rs pub struct Mutex<T: ?Sized> { · line 146

Quoted 10 lines
src/mutex.rs +2 -2
@@ -139,8 +139,8 @@ pub struct Mutex<T: ?Sized> {
      data: UnsafeCell<T>,
  }
 
-unsafe impl<T: Sync + Send> Send for Mutex<T> {}
-unsafe impl<T: Sync + Send> Sync for Mutex<T> {}
+unsafe impl<T: ?Sized + Send> Send for Mutex<T> {}
+unsafe impl<T: ?Sized + Send> Sync for Mutex<T> {}
 
  impl<T> Mutex<T> {
      /// Create a new mutex for guarding `data`, using the properties

Merged, thanks (short log fixed up marginally to remove redundant information).

Signature · 1 line
Philippe.