@@ -157,37 +157,34 @@ fn kind() -> Kind {
157
157
return ret;
158
158
}
159
159
160
- pub struct ReentrantMutex { inner : MaybeUninit < UnsafeCell < c:: CRITICAL_SECTION > > }
160
+ pub struct ReentrantMutex { inner : UnsafeCell < MaybeUninit < c:: CRITICAL_SECTION > > }
161
161
162
162
unsafe impl Send for ReentrantMutex { }
163
163
unsafe impl Sync for ReentrantMutex { }
164
164
165
165
impl ReentrantMutex {
166
166
pub fn uninitialized ( ) -> ReentrantMutex {
167
- ReentrantMutex { inner : MaybeUninit :: uninitialized ( ) }
167
+ ReentrantMutex { inner : UnsafeCell :: new ( MaybeUninit :: uninitialized ( ) ) }
168
168
}
169
169
170
170
pub unsafe fn init ( & mut self ) {
171
- // FIXME: Technically, this is calling `get_ref` on an uninitialized
172
- // `MaybeUninit`. Revisit this once we decided whether that is valid
173
- // or not.
174
- c:: InitializeCriticalSection ( self . inner . get_ref ( ) . get ( ) ) ;
171
+ c:: InitializeCriticalSection ( self . inner . get ( ) . as_mut_ptr ( ) ) ;
175
172
}
176
173
177
174
pub unsafe fn lock ( & self ) {
178
- c:: EnterCriticalSection ( self . inner . get_ref ( ) . get ( ) ) ;
175
+ c:: EnterCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
179
176
}
180
177
181
178
#[ inline]
182
179
pub unsafe fn try_lock ( & self ) -> bool {
183
- c:: TryEnterCriticalSection ( self . inner . get_ref ( ) . get ( ) ) != 0
180
+ c:: TryEnterCriticalSection ( self . inner . get ( ) . get_ref ( ) ) != 0
184
181
}
185
182
186
183
pub unsafe fn unlock ( & self ) {
187
- c:: LeaveCriticalSection ( self . inner . get_ref ( ) . get ( ) ) ;
184
+ c:: LeaveCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
188
185
}
189
186
190
187
pub unsafe fn destroy ( & self ) {
191
- c:: DeleteCriticalSection ( self . inner . get_ref ( ) . get ( ) ) ;
188
+ c:: DeleteCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
192
189
}
193
190
}
0 commit comments