File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,13 @@ impl Mutex {
1919 }
2020
2121 #[ inline]
22+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_try_lock" ) ]
2223 pub fn try_lock ( & self ) -> bool {
2324 self . futex . compare_exchange ( UNLOCKED , LOCKED , Acquire , Relaxed ) . is_ok ( )
2425 }
2526
2627 #[ inline]
28+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_lock" ) ]
2729 pub fn lock ( & self ) {
2830 if self . futex . compare_exchange ( UNLOCKED , LOCKED , Acquire , Relaxed ) . is_err ( ) {
2931 self . lock_contended ( ) ;
@@ -80,6 +82,7 @@ impl Mutex {
8082 }
8183
8284 #[ inline]
85+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_unlock" ) ]
8386 pub unsafe fn unlock ( & self ) {
8487 if self . futex . swap ( UNLOCKED , Release ) == CONTENDED {
8588 // We only wake up one thread. When that thread locks the mutex, it
Original file line number Diff line number Diff line change @@ -28,20 +28,23 @@ impl Mutex {
2828 }
2929
3030 #[ inline]
31+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_lock" ) ]
3132 pub fn lock ( & self ) {
3233 // SAFETY: we call `init` above, therefore reentrant locking is safe.
3334 // In `drop` we ensure that the mutex is not destroyed while locked.
3435 unsafe { self . get ( ) . lock ( ) }
3536 }
3637
3738 #[ inline]
39+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_unlock" ) ]
3840 pub unsafe fn unlock ( & self ) {
3941 // SAFETY: the mutex can only be locked if it is already initialized
4042 // and we observed this initialization since we observed the locking.
4143 unsafe { self . pal . get_unchecked ( ) . unlock ( ) }
4244 }
4345
4446 #[ inline]
47+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_try_lock" ) ]
4548 pub fn try_lock ( & self ) -> bool {
4649 // SAFETY: we call `init` above, therefore reentrant locking is safe.
4750 // In `drop` we ensure that the mutex is not destroyed while locked.
You can’t perform that action at this time.
0 commit comments