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};
2323use crate :: mem:: { self , MaybeUninit } ;
2424use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
2525use crate :: sys:: c;
26- use crate :: sys:: compat;
2726
2827pub struct Mutex {
2928 // This is either directly an SRWLOCK (if supported), or a Box<Inner> otherwise.
@@ -40,8 +39,8 @@ struct Inner {
4039
4140#[ derive( Clone , Copy ) ]
4241enum Kind {
43- SRWLock = 1 ,
44- CriticalSection = 2 ,
42+ SRWLock ,
43+ CriticalSection ,
4544}
4645
4746#[ inline]
@@ -130,21 +129,11 @@ impl Mutex {
130129}
131130
132131fn 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
140136 }
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
148137}
149138
150139pub struct ReentrantMutex {
You can’t perform that action at this time.
0 commit comments