1- #![ deny( unsafe_op_in_unsafe_fn) ]
2-
31use crate :: ffi:: c_void;
42use crate :: ptr;
53use crate :: sync:: atomic:: { AtomicUsize , Ordering :: SeqCst } ;
@@ -25,43 +23,33 @@ impl Condvar {
2523 }
2624
2725 pub unsafe fn init ( & mut self ) {
28- unsafe {
29- let _ = abi:: sem_init ( & mut self . sem1 as * mut * const c_void , 0 ) ;
30- let _ = abi:: sem_init ( & mut self . sem2 as * mut * const c_void , 0 ) ;
31- }
26+ let _ = abi:: sem_init ( & mut self . sem1 as * mut * const c_void , 0 ) ;
27+ let _ = abi:: sem_init ( & mut self . sem2 as * mut * const c_void , 0 ) ;
3228 }
3329
3430 pub unsafe fn notify_one ( & self ) {
3531 if self . counter . load ( SeqCst ) > 0 {
3632 self . counter . fetch_sub ( 1 , SeqCst ) ;
37- unsafe {
38- abi:: sem_post ( self . sem1 ) ;
39- abi:: sem_timedwait ( self . sem2 , 0 ) ;
40- }
33+ abi:: sem_post ( self . sem1 ) ;
34+ abi:: sem_timedwait ( self . sem2 , 0 ) ;
4135 }
4236 }
4337
4438 pub unsafe fn notify_all ( & self ) {
4539 let counter = self . counter . swap ( 0 , SeqCst ) ;
4640 for _ in 0 ..counter {
47- unsafe {
48- abi:: sem_post ( self . sem1 ) ;
49- }
41+ abi:: sem_post ( self . sem1 ) ;
5042 }
5143 for _ in 0 ..counter {
52- unsafe {
53- abi:: sem_timedwait ( self . sem2 , 0 ) ;
54- }
44+ abi:: sem_timedwait ( self . sem2 , 0 ) ;
5545 }
5646 }
5747
5848 pub unsafe fn wait ( & self , mutex : & Mutex ) {
5949 self . counter . fetch_add ( 1 , SeqCst ) ;
6050 mutex. unlock ( ) ;
61- unsafe {
62- abi:: sem_timedwait ( self . sem1 , 0 ) ;
63- abi:: sem_post ( self . sem2 ) ;
64- }
51+ abi:: sem_timedwait ( self . sem1 , 0 ) ;
52+ abi:: sem_post ( self . sem2 ) ;
6553 mutex. lock ( ) ;
6654 }
6755
@@ -70,9 +58,7 @@ impl Condvar {
7058 }
7159
7260 pub unsafe fn destroy ( & self ) {
73- unsafe {
74- let _ = abi:: sem_destroy ( self . sem1 ) ;
75- let _ = abi:: sem_destroy ( self . sem2 ) ;
76- }
61+ let _ = abi:: sem_destroy ( self . sem1 ) ;
62+ let _ = abi:: sem_destroy ( self . sem2 ) ;
7763 }
7864}
0 commit comments