File tree Expand file tree Collapse file tree 1 file changed +6
-17
lines changed
library/std/src/sys/windows Expand file tree Collapse file tree 1 file changed +6
-17
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ use crate::cell::{Cell, UnsafeCell};
23
23
use crate :: mem:: { self , MaybeUninit } ;
24
24
use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
25
25
use crate :: sys:: c;
26
- use crate :: sys:: compat;
27
26
28
27
pub struct Mutex {
29
28
// This is either directly an SRWLOCK (if supported), or a Box<Inner> otherwise.
@@ -40,8 +39,8 @@ struct Inner {
40
39
41
40
#[ derive( Clone , Copy ) ]
42
41
enum Kind {
43
- SRWLock = 1 ,
44
- CriticalSection = 2 ,
42
+ SRWLock ,
43
+ CriticalSection ,
45
44
}
46
45
47
46
#[ inline]
@@ -130,21 +129,11 @@ impl Mutex {
130
129
}
131
130
132
131
fn kind ( ) -> Kind {
133
- static KIND : AtomicUsize = AtomicUsize :: new ( 0 ) ;
134
-
135
- let val = KIND . load ( Ordering :: SeqCst ) ;
136
- if val == Kind :: SRWLock as usize {
137
- return Kind :: SRWLock ;
138
- } else if val == Kind :: CriticalSection as usize {
139
- return Kind :: CriticalSection ;
132
+ if c:: AcquireSRWLockExclusive :: is_available ( ) {
133
+ Kind :: SRWLock
134
+ } else {
135
+ Kind :: CriticalSection
140
136
}
141
-
142
- let ret = match compat:: lookup ( "kernel32" , "AcquireSRWLockExclusive" ) {
143
- None => Kind :: CriticalSection ,
144
- Some ( ..) => Kind :: SRWLock ,
145
- } ;
146
- KIND . store ( ret as usize , Ordering :: SeqCst ) ;
147
- ret
148
137
}
149
138
150
139
pub struct ReentrantMutex {
You can’t perform that action at this time.
0 commit comments