Skip to main content

Crate philiprehberger_task_queue

Crate philiprehberger_task_queue 

Source
Expand description

In-process thread-based task queue with priority and concurrency control.

This crate provides a simple task queue that runs closures on a pool of worker threads. Tasks can be submitted with different priorities, and higher-priority tasks are executed first.

§Example

use philiprehberger_task_queue::{TaskQueue, Priority};

let queue = TaskQueue::new(2);

let handle = queue.submit(|| 1 + 1);
assert_eq!(handle.join().unwrap(), 2);

let handle = queue.submit_with_priority(Priority::High, || "done");
assert_eq!(handle.join().unwrap(), "done");

queue.shutdown();

Structs§

TaskHandle
A handle to a submitted task, used to retrieve the result.
TaskQueue
A thread-based task queue with configurable concurrency and priority scheduling.
TaskQueueStats
Snapshot of task queue statistics for observability.

Enums§

Priority
Task execution priority.
TaskError
Error returned when a task fails to produce a result.