Module task

Module task 

Source
Expand description

Long-running background task infrastructure.

This module provides a trait-based system for defining and managing background tasks that run alongside the main application loop.

§Architecture

§Example

use cadmus_core::task::{BackgroundTask, TaskId, ShutdownSignal};
use std::sync::mpsc::Sender;
use cadmus_core::view::Event;

struct MyTask;

impl BackgroundTask for MyTask {
    fn id(&self) -> TaskId {
        TaskId::MyTask
    }

    fn run(&mut self, hub: &Sender<Event>, shutdown: &ShutdownSignal) {
        while !shutdown.should_stop() {
            // Do work...
            if shutdown.wait(Duration::from_secs(60)) {
                break;
            }
        }
    }
}

Modules§

dbus_monitor 🔒
D-Bus system bus monitor for debugging.
hello_world 🔒
Example background task for testing the task infrastructure.
wifi_status_monitor 🔒
WiFi status monitor using dhcpcd-dbus.

Structs§

RunningTask 🔒
ShutdownSignal
Signal for coordinating graceful shutdown of background tasks.
TaskManager
Manages the lifecycle of background tasks.

Enums§

TaskError
Errors that can occur during task management operations.
TaskId
Unique identifier for a background task.

Traits§

BackgroundTask
A long-running background task.

Functions§

register_startup_tasks
Registers background tasks that run at startup.