Skip to main content

spawn_rebuild_worker

Function spawn_rebuild_worker 

Source
pub fn spawn_rebuild_worker<F>(livereload: LiveReload, rebuild: F) -> TickSender
where F: FnMut() -> Result<(), String> + Send + 'static,
Expand description

Spawn the rebuild worker on a dedicated OS thread and return the sender used to enqueue rebuild ticks. The watcher closure should call tx.try_send(()) for every filesystem event burst — failed sends (channel full) are intentional coalescing.

The closure runs synchronously on the worker thread, so it may use blocking I/O freely. It returns Ok(()) on success or Err(msg) with a user-facing message on failure; the worker handles printing and broadcasting based on the result.

The returned TickSender does not need to be held to keep the worker alive — the worker stops only when every clone of the sender is dropped.