diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2023-01-25 11:23:46 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2023-01-25 11:31:19 +0300 |
commit | 3b4c48d9f55ae5bfb6eb4fe485edf54f8916d955 (patch) | |
tree | 69f065a49d4035b924d0c1f7025186d597a55590 /generic/threadshare/src | |
parent | ad3f1cf534b475d47d4ef4d0e8916d507c6e56e5 (diff) |
Fix various new clippy warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1062>
Diffstat (limited to 'generic/threadshare/src')
-rw-r--r-- | generic/threadshare/src/runtime/executor/context.rs | 2 | ||||
-rw-r--r-- | generic/threadshare/src/runtime/executor/scheduler.rs | 2 | ||||
-rw-r--r-- | generic/threadshare/src/runtime/task.rs | 96 | ||||
-rw-r--r-- | generic/threadshare/src/socket.rs | 4 | ||||
-rw-r--r-- | generic/threadshare/src/tcpclientsrc/imp.rs | 3 |
5 files changed, 63 insertions, 44 deletions
diff --git a/generic/threadshare/src/runtime/executor/context.rs b/generic/threadshare/src/runtime/executor/context.rs index e12fdcbbb..8f4321514 100644 --- a/generic/threadshare/src/runtime/executor/context.rs +++ b/generic/threadshare/src/runtime/executor/context.rs @@ -469,7 +469,7 @@ mod tests { // The last sub task should be simply dropped at this point match receiver.try_next() { Ok(None) | Err(_) => (), - other => panic!("Unexpected {:?}", other), + other => panic!("Unexpected {other:?}"), } } diff --git a/generic/threadshare/src/runtime/executor/scheduler.rs b/generic/threadshare/src/runtime/executor/scheduler.rs index bf7c65c47..8552a5201 100644 --- a/generic/threadshare/src/runtime/executor/scheduler.rs +++ b/generic/threadshare/src/runtime/executor/scheduler.rs @@ -201,7 +201,7 @@ impl Scheduler { let mut now; // This is to ensure reactor invocation on the first iteration. - let mut last_react = Instant::now() - self.max_throttling; + let mut last_react = Instant::now().checked_sub(self.max_throttling).unwrap(); let mut tasks_checked; 'main: loop { // Only check I/O and timers every `max_throttling`. diff --git a/generic/threadshare/src/runtime/task.rs b/generic/threadshare/src/runtime/task.rs index 2277df941..0ac007746 100644 --- a/generic/threadshare/src/runtime/task.rs +++ b/generic/threadshare/src/runtime/task.rs @@ -1306,7 +1306,7 @@ mod tests { origin: Unprepared, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; gst::debug!(RUNTIME_CAT, "nominal: starting (async prepare)"); @@ -1356,7 +1356,7 @@ mod tests { state: Started, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } gst::debug!(RUNTIME_CAT, "nominal: pause cancelling try_next"); @@ -1559,7 +1559,7 @@ mod tests { state: Preparing, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } // Wait for state machine to reach Error @@ -1573,7 +1573,7 @@ mod tests { state: TaskState::Error, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } block_on(task.unprepare()).unwrap(); @@ -1636,7 +1636,8 @@ mod tests { let task = Task::default(); let (mut prepare_sender, prepare_receiver) = mpsc::channel(1); - let _ = task.prepare(TaskPrepareTest { prepare_receiver }, context); + let fut = task.prepare(TaskPrepareTest { prepare_receiver }, context); + drop(fut); let start_ctx = Context::acquire("prepare_start_ok_requester", Duration::ZERO).unwrap(); let (ready_sender, ready_receiver) = oneshot::channel(); @@ -1650,7 +1651,7 @@ mod tests { origin: Preparing, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } ready_sender.send(()).unwrap(); assert_eq!( @@ -1669,7 +1670,7 @@ mod tests { origin: Started, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } assert_eq!( stop_status.await.unwrap(), @@ -1687,7 +1688,7 @@ mod tests { origin: Stopped, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; assert_eq!( unprepare_status.await.unwrap(), @@ -1755,7 +1756,7 @@ mod tests { (Prepare, Unprepared) => { self.prepare_error_sender.send(()).await.unwrap(); } - other => panic!("action error for {:?}", other), + other => panic!("action error for {other:?}"), } Trigger::Error } @@ -1794,14 +1795,15 @@ mod tests { origin: Unprepared, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; let start_ctx = Context::acquire("prepare_start_error_requester", Duration::ZERO).unwrap(); let (ready_sender, ready_receiver) = oneshot::channel(); let start_handle = start_ctx.spawn(async move { gst::debug!(RUNTIME_CAT, "prepare_start_error: starting (Err)"); - let _ = task.start(); + let fut = task.start(); + drop(fut); ready_sender.send(()).unwrap(); // FIXME we loose the origin Trigger (Start) // and only get the Trigger returned by handle_action_error @@ -1812,7 +1814,7 @@ mod tests { state: Preparing, .. }) => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } let unprepare_status = task.unprepare(); @@ -1822,7 +1824,7 @@ mod tests { origin: TaskState::Error, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; assert_eq!( unprepare_status.await.unwrap(), @@ -1921,7 +1923,7 @@ mod tests { state: TaskState::Error, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } assert_eq!( @@ -1978,13 +1980,14 @@ mod tests { let (flush_start_sender, mut flush_start_receiver) = mpsc::channel(1); let (flush_stop_sender, mut flush_stop_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskFlushTest { flush_start_sender, flush_stop_sender, }, context, ); + drop(fut); gst::debug!(RUNTIME_CAT, "flush_regular_sync: start"); block_on(task.start()).unwrap(); @@ -2013,7 +2016,8 @@ mod tests { block_on(flush_stop_receiver.next()).unwrap(); - let _ = task.pause(); + let fut = task.pause(); + drop(fut); stop_then_unprepare(task); } @@ -2070,13 +2074,14 @@ mod tests { let (flush_start_sender, mut flush_start_receiver) = mpsc::channel(1); let (flush_stop_sender, mut flush_stop_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskFlushTest { flush_start_sender, flush_stop_sender, }, context, ); + drop(fut); gst::debug!(RUNTIME_CAT, "flush_regular_different_context: start"); task.start().block_on().unwrap(); @@ -2096,7 +2101,7 @@ mod tests { origin: Started, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; assert_eq!( flush_start_status.await.unwrap(), @@ -2115,7 +2120,7 @@ mod tests { origin: Flushing, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; assert_eq!( flush_stop_status.await_maybe_on_context().unwrap(), @@ -2182,13 +2187,14 @@ mod tests { let (flush_start_sender, mut flush_start_receiver) = mpsc::channel(1); let (flush_stop_sender, mut flush_stop_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskFlushTest { flush_start_sender, flush_stop_sender, }, context.clone(), ); + drop(fut); block_on(task.start()).unwrap(); @@ -2201,7 +2207,7 @@ mod tests { origin: Started, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; assert_eq!( flush_start_status.await.unwrap(), @@ -2220,7 +2226,7 @@ mod tests { origin: Flushing, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; assert_eq!( flush_stop_status.await.unwrap(), @@ -2264,7 +2270,7 @@ mod tests { origin: Started, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } Ok(()) } @@ -2286,15 +2292,17 @@ mod tests { let task = Task::default(); let (flush_start_sender, mut flush_start_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskFlushTest { task: task.clone(), flush_start_sender, }, context, ); + drop(fut); - let _ = task.start(); + let fut = task.start(); + drop(fut); gst::debug!( RUNTIME_CAT, @@ -2343,7 +2351,7 @@ mod tests { origin: Started, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } Ok(()) @@ -2366,15 +2374,17 @@ mod tests { let task = Task::default(); let (pause_sender, mut pause_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskStartTest { task: task.clone(), pause_sender, }, context, ); + drop(fut); - let _ = task.start(); + let fut = task.start(); + drop(fut); gst::debug!(RUNTIME_CAT, "pause_from_loop: awaiting pause notification"); block_on(pause_receiver.next()).unwrap(); @@ -2415,7 +2425,7 @@ mod tests { origin: Started, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } Ok(()) @@ -2438,16 +2448,18 @@ mod tests { let task = Task::default(); let (flush_stop_sender, mut flush_stop_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskFlushTest { task: task.clone(), flush_stop_sender, }, context, ); + drop(fut); task.start().block_on().unwrap(); - let _ = task.flush_start(); + let fut = task.flush_start(); + drop(fut); gst::debug!( RUNTIME_CAT, @@ -2514,7 +2526,7 @@ mod tests { let (started_sender, mut started_receiver) = mpsc::channel(1); let (flush_start_sender, mut flush_start_receiver) = mpsc::channel(1); let (flush_stop_sender, mut flush_stop_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskFlushTest { started_sender, flush_start_sender, @@ -2522,6 +2534,7 @@ mod tests { }, context, ); + drop(fut); // Pause, FlushStart, FlushStop, Start @@ -2629,7 +2642,7 @@ mod tests { let (started_sender, mut started_receiver) = mpsc::channel(1); let (flush_start_sender, mut flush_start_receiver) = mpsc::channel(1); let (flush_stop_sender, mut flush_stop_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskFlushTest { started_sender, flush_start_sender, @@ -2637,11 +2650,13 @@ mod tests { }, context, ); + drop(fut); // Pause, FlushStart, Start, FlushStop gst::debug!(RUNTIME_CAT, "pause_flushing_start: pausing"); - let _ = task.pause(); + let fut = task.pause(); + drop(fut); gst::debug!(RUNTIME_CAT, "pause_flushing_start: starting flush"); block_on(task.flush_start()).unwrap(); @@ -2723,13 +2738,14 @@ mod tests { let (flush_start_sender, mut flush_start_receiver) = mpsc::channel(1); let (flush_stop_sender, mut flush_stop_receiver) = mpsc::channel(1); - let _ = task.prepare( + let fut = task.prepare( TaskStartTest { flush_start_sender, flush_stop_sender, }, context, ); + drop(fut); let oob_context = Context::acquire("flush_concurrent_start_oob", Duration::from_millis(2)).unwrap(); @@ -2755,7 +2771,7 @@ mod tests { origin: Started, .. } => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), }; status.await.unwrap(); flush_start_receiver.next().await.unwrap(); @@ -2777,7 +2793,7 @@ mod tests { origin: PausedFlushing, target: Flushing, }) => (), - other => panic!("{:?}", other), + other => panic!("{other:?}"), } block_on(flush_start_handle).unwrap(); @@ -2848,16 +2864,18 @@ mod tests { let task = Task::default(); let (timer_elapsed_sender, timer_elapsed_receiver) = oneshot::channel(); - let _ = task.prepare( + let fut = task.prepare( TaskTimerTest { timer: None, timer_elapsed_sender: Some(timer_elapsed_sender), }, context, ); + drop(fut); gst::debug!(RUNTIME_CAT, "start_timer: start"); - let _ = task.start(); + let fut = task.start(); + drop(fut); block_on(timer_elapsed_receiver).unwrap(); gst::debug!(RUNTIME_CAT, "start_timer: timer elapsed received"); diff --git a/generic/threadshare/src/socket.rs b/generic/threadshare/src/socket.rs index 3ac650d94..a815c213b 100644 --- a/generic/threadshare/src/socket.rs +++ b/generic/threadshare/src/socket.rs @@ -111,8 +111,8 @@ impl error::Error for SocketError {} impl fmt::Display for SocketError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - SocketError::Gst(err) => write!(f, "flow error: {}", err), - SocketError::Io(err) => write!(f, "IO error: {}", err), + SocketError::Gst(err) => write!(f, "flow error: {err}"), + SocketError::Io(err) => write!(f, "IO error: {err}"), } } } diff --git a/generic/threadshare/src/tcpclientsrc/imp.rs b/generic/threadshare/src/tcpclientsrc/imp.rs index 71e702b59..cbbf2505f 100644 --- a/generic/threadshare/src/tcpclientsrc/imp.rs +++ b/generic/threadshare/src/tcpclientsrc/imp.rs @@ -434,13 +434,14 @@ impl TcpClientSrc { // Don't block on `prepare` as the socket connection takes time. // This will be performed in the background and we'll block on // `start` which will also ensure `prepare` completed successfully. - let _ = self + let fut = self .task .prepare( TcpClientSrcTask::new(self.obj().clone(), saddr, buffer_pool), context, ) .check()?; + drop(fut); gst::debug!(CAT, imp: self, "Preparing asynchronously"); |