@@ -64,10 +64,7 @@ impl Timer {
6464 // Iterate through Senders
6565 txs. lock ( ) ?. iter ( ) . for_each ( |tx| {
6666 // Send event to attached Sender
67- match tx. send ( current) {
68- Ok ( _) => { }
69- Err ( _) => { }
70- }
67+ if tx. send ( current) . is_ok ( ) { }
7168 } ) ;
7269 }
7370 } ) ) ;
@@ -151,12 +148,16 @@ impl Timer {
151148 let mut events = Vec :: with_capacity ( 1 ) ;
152149
153150 // wait for the timer to fire an event. This is function will block.
154- epoll_wait ( epoll_fd, events. as_mut_ptr ( ) , 1 , -1 ) ?;
151+ unsafe {
152+ epoll_wait ( epoll_fd, events. as_mut_ptr ( ) , 1 , -1 ) ?;
153+ }
155154
156155 // read the value from the timerfd. This is required to re-arm the timer.
157156 let mut buffer: u64 = 0 ;
158157 let bufptr: * mut _ = & mut buffer;
159- read ( timer_fd, bufptr as * mut libc:: c_void , 8 ) ?;
158+ unsafe {
159+ read ( timer_fd, bufptr as * mut libc:: c_void , 8 ) ?;
160+ }
160161
161162 Ok ( ( ) )
162163 }
@@ -217,15 +218,21 @@ pub fn epoll_ctl(
217218}
218219
219220/// libc::epoll_wait wrapper
220- pub fn epoll_wait (
221+ ///
222+ /// # Safety
223+ /// This function is a wrapper for libc::epoll_wait.
224+ pub unsafe fn epoll_wait (
221225 epoll_fd : i32 , events : * mut libc:: epoll_event , maxevents : libc:: c_int , timeout : libc:: c_int ,
222226) -> Result < ( ) > {
223- check_err ( unsafe { libc:: epoll_wait ( epoll_fd, events, maxevents, timeout) } ) ?;
227+ check_err ( libc:: epoll_wait ( epoll_fd, events, maxevents, timeout) ) ?;
224228 Ok ( ( ) )
225229}
226230
227231/// libc::read wrapper
228- pub fn read ( timer_fd : i32 , bufptr : * mut libc:: c_void , count : libc:: size_t ) -> Result < ( ) > {
229- check_err ( unsafe { libc:: read ( timer_fd, bufptr, count) } ) ?;
232+ ///
233+ /// # Safety
234+ /// This function is a wrapper for libc::read.
235+ pub unsafe fn read ( timer_fd : i32 , bufptr : * mut libc:: c_void , count : libc:: size_t ) -> Result < ( ) > {
236+ check_err ( libc:: read ( timer_fd, bufptr, count) ) ?;
230237 Ok ( ( ) )
231238}
0 commit comments