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 {
19
19
}
20
20
21
21
#[ inline]
22
+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_try_lock" ) ]
22
23
pub fn try_lock ( & self ) -> bool {
23
24
self . futex . compare_exchange ( UNLOCKED , LOCKED , Acquire , Relaxed ) . is_ok ( )
24
25
}
25
26
26
27
#[ inline]
28
+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_lock" ) ]
27
29
pub fn lock ( & self ) {
28
30
if self . futex . compare_exchange ( UNLOCKED , LOCKED , Acquire , Relaxed ) . is_err ( ) {
29
31
self . lock_contended ( ) ;
@@ -80,6 +82,7 @@ impl Mutex {
80
82
}
81
83
82
84
#[ inline]
85
+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_unlock" ) ]
83
86
pub unsafe fn unlock ( & self ) {
84
87
if self . futex . swap ( UNLOCKED , Release ) == CONTENDED {
85
88
// 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 {
28
28
}
29
29
30
30
#[ inline]
31
+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_lock" ) ]
31
32
pub fn lock ( & self ) {
32
33
// SAFETY: we call `init` above, therefore reentrant locking is safe.
33
34
// In `drop` we ensure that the mutex is not destroyed while locked.
34
35
unsafe { self . get ( ) . lock ( ) }
35
36
}
36
37
37
38
#[ inline]
39
+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_unlock" ) ]
38
40
pub unsafe fn unlock ( & self ) {
39
41
// SAFETY: the mutex can only be locked if it is already initialized
40
42
// and we observed this initialization since we observed the locking.
41
43
unsafe { self . pal . get_unchecked ( ) . unlock ( ) }
42
44
}
43
45
44
46
#[ inline]
47
+ #[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_try_lock" ) ]
45
48
pub fn try_lock ( & self ) -> bool {
46
49
// SAFETY: we call `init` above, therefore reentrant locking is safe.
47
50
// In `drop` we ensure that the mutex is not destroyed while locked.
You can’t perform that action at this time.
0 commit comments