@@ -157,37 +157,34 @@ fn kind() -> Kind {
157157 return ret;
158158}
159159
160- pub struct ReentrantMutex { inner : MaybeUninit < UnsafeCell < c:: CRITICAL_SECTION > > }
160+ pub struct ReentrantMutex { inner : UnsafeCell < MaybeUninit < c:: CRITICAL_SECTION > > }
161161
162162unsafe impl Send for ReentrantMutex { }
163163unsafe impl Sync for ReentrantMutex { }
164164
165165impl ReentrantMutex {
166166 pub fn uninitialized ( ) -> ReentrantMutex {
167- ReentrantMutex { inner : MaybeUninit :: uninitialized ( ) }
167+ ReentrantMutex { inner : UnsafeCell :: new ( MaybeUninit :: uninitialized ( ) ) }
168168 }
169169
170170 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 ( ) ) ;
175172 }
176173
177174 pub unsafe fn lock ( & self ) {
178- c:: EnterCriticalSection ( self . inner . get_ref ( ) . get ( ) ) ;
175+ c:: EnterCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
179176 }
180177
181178 #[ inline]
182179 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
184181 }
185182
186183 pub unsafe fn unlock ( & self ) {
187- c:: LeaveCriticalSection ( self . inner . get_ref ( ) . get ( ) ) ;
184+ c:: LeaveCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
188185 }
189186
190187 pub unsafe fn destroy ( & self ) {
191- c:: DeleteCriticalSection ( self . inner . get_ref ( ) . get ( ) ) ;
188+ c:: DeleteCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
192189 }
193190}
0 commit comments