@@ -90,49 +90,7 @@ impl Mutex {
9090 }
9191}
9292
93- pub struct ReentrantMutex {
94- inner : UnsafeCell < libc:: pthread_mutex_t > ,
95- }
96-
97- unsafe impl Send for ReentrantMutex { }
98- unsafe impl Sync for ReentrantMutex { }
99-
100- impl ReentrantMutex {
101- pub const unsafe fn uninitialized ( ) -> ReentrantMutex {
102- ReentrantMutex { inner : UnsafeCell :: new ( libc:: PTHREAD_MUTEX_INITIALIZER ) }
103- }
104-
105- pub unsafe fn init ( & self ) {
106- let mut attr = MaybeUninit :: < libc:: pthread_mutexattr_t > :: uninit ( ) ;
107- cvt_nz ( libc:: pthread_mutexattr_init ( attr. as_mut_ptr ( ) ) ) . unwrap ( ) ;
108- let attr = PthreadMutexAttr ( & mut attr) ;
109- cvt_nz ( libc:: pthread_mutexattr_settype ( attr. 0 . as_mut_ptr ( ) , libc:: PTHREAD_MUTEX_RECURSIVE ) )
110- . unwrap ( ) ;
111- cvt_nz ( libc:: pthread_mutex_init ( self . inner . get ( ) , attr. 0 . as_ptr ( ) ) ) . unwrap ( ) ;
112- }
113-
114- pub unsafe fn lock ( & self ) {
115- let result = libc:: pthread_mutex_lock ( self . inner . get ( ) ) ;
116- debug_assert_eq ! ( result, 0 ) ;
117- }
118-
119- #[ inline]
120- pub unsafe fn try_lock ( & self ) -> bool {
121- libc:: pthread_mutex_trylock ( self . inner . get ( ) ) == 0
122- }
123-
124- pub unsafe fn unlock ( & self ) {
125- let result = libc:: pthread_mutex_unlock ( self . inner . get ( ) ) ;
126- debug_assert_eq ! ( result, 0 ) ;
127- }
128-
129- pub unsafe fn destroy ( & self ) {
130- let result = libc:: pthread_mutex_destroy ( self . inner . get ( ) ) ;
131- debug_assert_eq ! ( result, 0 ) ;
132- }
133- }
134-
135- struct PthreadMutexAttr < ' a > ( & ' a mut MaybeUninit < libc:: pthread_mutexattr_t > ) ;
93+ pub ( super ) struct PthreadMutexAttr < ' a > ( pub & ' a mut MaybeUninit < libc:: pthread_mutexattr_t > ) ;
13694
13795impl Drop for PthreadMutexAttr < ' _ > {
13896 fn drop ( & mut self ) {
0 commit comments