File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 11use std:: cell:: UnsafeCell ;
22use std:: fmt;
3+ use std:: future:: Future ;
34use std:: isize;
45use std:: ops:: { Deref , DerefMut } ;
56use std:: pin:: Pin ;
67use std:: process;
7- use std:: future:: Future ;
88use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
99
1010use crate :: sync:: WakerSet ;
@@ -301,7 +301,11 @@ impl<T: ?Sized> RwLock<T> {
301301 /// # })
302302 /// ```
303303 pub fn try_write ( & self ) -> Option < RwLockWriteGuard < ' _ , T > > {
304- if self . state . compare_and_swap ( 0 , WRITE_LOCK , Ordering :: SeqCst ) == 0 {
304+ if self
305+ . state
306+ . compare_exchange ( 0 , WRITE_LOCK , Ordering :: SeqCst )
307+ . is_ok ( )
308+ {
305309 Some ( RwLockWriteGuard ( self ) )
306310 } else {
307311 None
@@ -318,7 +322,10 @@ impl<T: ?Sized> RwLock<T> {
318322 /// let lock = RwLock::new(10);
319323 /// assert_eq!(lock.into_inner(), 10);
320324 /// ```
321- pub fn into_inner ( self ) -> T where T : Sized {
325+ pub fn into_inner ( self ) -> T
326+ where
327+ T : Sized ,
328+ {
322329 self . value . into_inner ( )
323330 }
324331
Original file line number Diff line number Diff line change @@ -124,9 +124,9 @@ impl<T: Send + 'static> LocalKey<T> {
124124 std:: process:: abort ( ) ;
125125 }
126126
127- match key. compare_and_swap ( 0 , counter, Ordering :: AcqRel ) {
128- 0 => counter,
129- k => k,
127+ match key. compare_exchange ( 0 , counter, Ordering :: AcqRel ) {
128+ Ok ( _ ) => counter,
129+ Err ( k ) => k,
130130 }
131131 }
132132
You can’t perform that action at this time.
0 commit comments