1
1
use crate :: cell:: UnsafeCell ;
2
2
use crate :: ptr;
3
- use crate :: sync:: atomic:: { AtomicUsize , Ordering :: SeqCst } ;
3
+ use crate :: sync:: atomic:: { AtomicU8 , Ordering :: SeqCst } ;
4
4
5
5
use crate :: sys:: ffi:: * ;
6
6
7
7
pub struct Mutex {
8
8
inner : UnsafeCell < SemaphoreHandle_t > ,
9
- initialized : AtomicUsize ,
9
+ initialized : AtomicU8 ,
10
10
}
11
11
12
12
unsafe impl Send for Mutex { }
13
13
unsafe impl Sync for Mutex { }
14
14
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 ;
19
19
20
20
#[ allow( dead_code) ] // sys isn't exported yet
21
21
impl Mutex {
22
22
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 ) }
24
24
}
25
25
26
26
#[ inline]
@@ -89,7 +89,7 @@ impl Drop for Mutex {
89
89
90
90
pub struct ReentrantMutex {
91
91
inner : UnsafeCell < SemaphoreHandle_t > ,
92
- initialized : AtomicUsize ,
92
+ initialized : AtomicU8 ,
93
93
}
94
94
95
95
unsafe impl Send for ReentrantMutex { }
@@ -99,7 +99,7 @@ impl ReentrantMutex {
99
99
pub const unsafe fn uninitialized ( ) -> ReentrantMutex {
100
100
ReentrantMutex {
101
101
inner : UnsafeCell :: new ( ptr:: null_mut ( ) ) ,
102
- initialized : AtomicUsize :: new ( UNINITIALIZED ) ,
102
+ initialized : AtomicU8 :: new ( UNINITIALIZED ) ,
103
103
}
104
104
}
105
105
0 commit comments