@@ -201,7 +201,7 @@ impl<'a, T: 'a + Score> LockableScore<'a> for RefCell<T> {
201
201
#[ cfg( c_bindings) ]
202
202
/// A concrete implementation of [`LockableScore`] which supports multi-threading.
203
203
pub struct MultiThreadedLockableScore < S : Score > {
204
- score : Mutex < S > ,
204
+ score : crate :: sync :: RwLock < S > ,
205
205
}
206
206
#[ cfg( c_bindings) ]
207
207
/// A locked `MultiThreadedLockableScore`.
@@ -224,6 +224,7 @@ impl<'a, T: Score + 'a> Score for MultiThreadedScoreLock<'a, T> {
224
224
self . 0 . probe_successful ( path)
225
225
}
226
226
}
227
+
227
228
#[ cfg( c_bindings) ]
228
229
impl < ' a , T : Score + ' a > Writeable for MultiThreadedScoreLock < ' a , T > {
229
230
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
@@ -237,11 +238,11 @@ impl<'a, T: Score + 'a> LockableScore<'a> for MultiThreadedLockableScore<T> {
237
238
type WriteLocked = MultiThreadedScoreLock < ' a , T > ;
238
239
239
240
fn write_lock ( & ' a self ) -> MultiThreadedScoreLock < ' a , T > {
240
- MultiThreadedScoreLock ( Mutex :: lock ( & self . score ) . unwrap ( ) )
241
+ MultiThreadedScoreLock ( crate :: sync :: RwLock :: write ( & self . score ) . unwrap ( ) )
241
242
}
242
243
243
244
fn score_lock ( & ' a self ) -> MultiThreadedScoreLock < ' a , T > {
244
- MultiThreadedScoreLock ( Mutex :: lock ( & self . score ) . unwrap ( ) )
245
+ MultiThreadedScoreLock ( crate :: sync :: RwLock :: lock ( & self . score ) . unwrap ( ) )
245
246
}
246
247
}
247
248
@@ -259,7 +260,7 @@ impl<'a, T: Score + 'a> WriteableScore<'a> for MultiThreadedLockableScore<T> {}
259
260
impl < T : Score > MultiThreadedLockableScore < T > {
260
261
/// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`].
261
262
pub fn new ( score : T ) -> Self {
262
- MultiThreadedLockableScore { score : Mutex :: new ( score) }
263
+ MultiThreadedLockableScore { score : crate :: sync :: RwLock :: new ( score) }
263
264
}
264
265
}
265
266
0 commit comments