From ca6a39207d95832705816b49278cfceb81da4c32 Mon Sep 17 00:00:00 2001 From: Marc Riegel Date: Wed, 9 Jul 2025 09:33:18 +0200 Subject: [PATCH] Remove unsafe Send and Sync impls and cleanup comments and dividers --- src/process_manager.rs | 22 +++------------------- src/runtime_guard.rs | 5 ----- src/runtime_ticker.rs | 3 --- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/process_manager.rs b/src/process_manager.rs index 60ec9b7..905c0bf 100644 --- a/src/process_manager.rs +++ b/src/process_manager.rs @@ -95,10 +95,6 @@ pub struct ProcessManager { pub(crate) auto_cleanup: bool, } -/* ========================================================================== */ -/* Construction / configuration */ -/* ========================================================================== */ - impl ProcessManager { /// New manager with auto-cleanup of finished children enabled. pub fn new() -> Self { @@ -167,10 +163,6 @@ impl ProcessManager { } } -/* ========================================================================== */ -/* Runnable implementation */ -/* ========================================================================== */ - impl Runnable for ProcessManager { fn process_start(&self) -> ProcFuture<'_> { let inner = Arc::clone(&self.inner); @@ -221,7 +213,7 @@ impl Runnable for ProcessManager { #[cfg(feature = "tracing")] { for child in self.inner.processes.lock().unwrap().iter() { - ::tracing::info!( + ::tracing::debug!( "Process {}: running={:?}", child.proc.process_name(), !child.join_handle.is_finished() @@ -271,9 +263,9 @@ impl Runnable for ProcessManager { match first_error { Some(error) => { #[cfg(feature = "tracing")] - ::tracing::info!("Shutdown process manager {name} with error: {error:?}"); + ::tracing::warn!("Shutdown process manager {name} with error: {error:?}"); #[cfg(all(not(feature = "tracing"), feature = "log"))] - ::log::info!("Shutdown process manager {name} with error: {error:?}"); + ::log::warn!("Shutdown process manager {name} with error: {error:?}"); #[cfg(all(not(feature = "tracing"), not(feature = "log")))] eprintln!("Shutdown process manager {name} with error: {error:?}"); Err(error) @@ -312,10 +304,6 @@ impl Default for ProcessManager { } } -/* ========================================================================== */ -/* Control Handle */ -/* ========================================================================== */ - struct Handle { inner: Arc, } @@ -396,10 +384,6 @@ impl ProcessControlHandler for Handle { } } -/* ========================================================================== */ -/* Helper – spawn a single child */ -/* ========================================================================== */ - fn spawn_child(id: usize, proc: Arc, inner: Arc) -> JoinHandle<()> { // increment *before* spawning the task – guarantees the counter is in sync inner.active.fetch_add(1, Ordering::SeqCst); diff --git a/src/runtime_guard.rs b/src/runtime_guard.rs index 143c775..46ec46f 100644 --- a/src/runtime_guard.rs +++ b/src/runtime_guard.rs @@ -15,11 +15,6 @@ struct Inner { control_ch_sender: Arc>>, } -// SAFETY: All interior mutability is protected by `tokio::sync::Mutex`, so -// `&RuntimeGuard` can be safely shared between threads. -unsafe impl Send for RuntimeGuard {} -unsafe impl Sync for RuntimeGuard {} - impl RuntimeGuard { pub fn new() -> Self { let (sender, mut receiver) = tokio::sync::mpsc::channel(1); diff --git a/src/runtime_ticker.rs b/src/runtime_ticker.rs index f68822e..1be6467 100644 --- a/src/runtime_ticker.rs +++ b/src/runtime_ticker.rs @@ -8,9 +8,6 @@ pub struct RuntimeTicker { control_ch_receiver: Arc>>, } -unsafe impl Send for RuntimeTicker {} -unsafe impl Sync for RuntimeTicker {} - impl RuntimeTicker { pub(crate) fn new() -> (Self, tokio::sync::mpsc::Sender) { let (sender, receiver) = tokio::sync::mpsc::channel(1);