File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
library/std/src/sys/sync/mutex Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,14 @@ impl Mutex {
19
19
}
20
20
21
21
#[ inline]
22
+ // Make this a diagnostic item for Miri's concurrency model checker.
22
23
#[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_try_lock" ) ]
23
24
pub fn try_lock ( & self ) -> bool {
24
25
self . futex . compare_exchange ( UNLOCKED , LOCKED , Acquire , Relaxed ) . is_ok ( )
25
26
}
26
27
27
28
#[ inline]
29
+ // Make this a diagnostic item for Miri's concurrency model checker.
28
30
#[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_lock" ) ]
29
31
pub fn lock ( & self ) {
30
32
if self . futex . compare_exchange ( UNLOCKED , LOCKED , Acquire , Relaxed ) . is_err ( ) {
@@ -82,6 +84,7 @@ impl Mutex {
82
84
}
83
85
84
86
#[ inline]
87
+ // Make this a diagnostic item for Miri's concurrency model checker.
85
88
#[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_unlock" ) ]
86
89
pub unsafe fn unlock ( & self ) {
87
90
if self . futex . swap ( UNLOCKED , Release ) == CONTENDED {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ impl Mutex {
28
28
}
29
29
30
30
#[ inline]
31
+ // Make this a diagnostic item for Miri's concurrency model checker.
31
32
#[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_lock" ) ]
32
33
pub fn lock ( & self ) {
33
34
// SAFETY: we call `init` above, therefore reentrant locking is safe.
@@ -36,6 +37,7 @@ impl Mutex {
36
37
}
37
38
38
39
#[ inline]
40
+ // Make this a diagnostic item for Miri's concurrency model checker.
39
41
#[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_unlock" ) ]
40
42
pub unsafe fn unlock ( & self ) {
41
43
// SAFETY: the mutex can only be locked if it is already initialized
@@ -44,6 +46,7 @@ impl Mutex {
44
46
}
45
47
46
48
#[ inline]
49
+ // Make this a diagnostic item for Miri's concurrency model checker.
47
50
#[ cfg_attr( not( test) , rustc_diagnostic_item = "sys_mutex_try_lock" ) ]
48
51
pub fn try_lock ( & self ) -> bool {
49
52
// SAFETY: we call `init` above, therefore reentrant locking is safe.
You can’t perform that action at this time.
0 commit comments