11use crate :: cell:: UnsafeCell ;
22use crate :: ptr;
3- use crate :: sync:: atomic:: { AtomicUsize , Ordering :: SeqCst } ;
3+ use crate :: sync:: atomic:: { AtomicU8 , Ordering :: SeqCst } ;
44
55use crate :: sys:: ffi:: * ;
66
77pub struct Mutex {
88 inner : UnsafeCell < SemaphoreHandle_t > ,
9- initialized : AtomicUsize ,
9+ initialized : AtomicU8 ,
1010}
1111
1212unsafe impl Send for Mutex { }
1313unsafe impl Sync for Mutex { }
1414
15- const UNINITIALIZING : usize = 3 ;
16- const UNINITIALIZED : usize = 2 ;
17- const INITIALIZING : usize = 1 ;
18- const INITIALIZED : usize = 0 ;
15+ const UNINITIALIZING : u8 = 3 ;
16+ const UNINITIALIZED : u8 = 2 ;
17+ const INITIALIZING : u8 = 1 ;
18+ const INITIALIZED : u8 = 0 ;
1919
2020#[ allow( dead_code) ] // sys isn't exported yet
2121impl Mutex {
2222 pub const fn new ( ) -> Mutex {
23- Mutex { inner : UnsafeCell :: new ( ptr:: null_mut ( ) ) , initialized : AtomicUsize :: new ( UNINITIALIZED ) }
23+ Mutex { inner : UnsafeCell :: new ( ptr:: null_mut ( ) ) , initialized : AtomicU8 :: new ( UNINITIALIZED ) }
2424 }
2525
2626 #[ inline]
@@ -89,7 +89,7 @@ impl Drop for Mutex {
8989
9090pub struct ReentrantMutex {
9191 inner : UnsafeCell < SemaphoreHandle_t > ,
92- initialized : AtomicUsize ,
92+ initialized : AtomicU8 ,
9393}
9494
9595unsafe impl Send for ReentrantMutex { }
@@ -99,7 +99,7 @@ impl ReentrantMutex {
9999 pub const unsafe fn uninitialized ( ) -> ReentrantMutex {
100100 ReentrantMutex {
101101 inner : UnsafeCell :: new ( ptr:: null_mut ( ) ) ,
102- initialized : AtomicUsize :: new ( UNINITIALIZED ) ,
102+ initialized : AtomicU8 :: new ( UNINITIALIZED ) ,
103103 }
104104 }
105105
0 commit comments