You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Controls scheduling behavior. Set via builder methods or pass directly to Scheduler::new().
Field
Type
Default
Description
max_concurrency
usize
4
Maximum concurrent running tasks. Adjustable at runtime via set_max_concurrency().
max_retries
i32
3
Retry limit before a task is permanently failed.
preempt_priority
Priority
REALTIME (0)
Tasks at or above this priority trigger preemption of lower-priority work.
poll_interval
Duration
500ms
Sleep between scheduler dispatch cycles. The scheduler also wakes on Notify signals.
throughput_sample_size
i32
20
Number of recent completions used for throughput-based progress extrapolation.
shutdown_mode
ShutdownMode
Hard
Hard cancels all tasks immediately. Graceful(Duration) waits up to the timeout.
Builder methods
use std::time::Duration;use taskmill::{Scheduler,Priority,ShutdownMode};let scheduler = Scheduler::builder().max_concurrency(8).max_retries(5).preempt_priority(Priority::HIGH).poll_interval(Duration::from_millis(250)).shutdown_mode(ShutdownMode::Graceful(Duration::from_secs(30))).build().await?;
StoreConfig
Controls the SQLite connection pool and history retention.
Field
Type
Default
Description
max_connections
u32
16
SQLite connection pool size.
retention_policy
Option<RetentionPolicy>
None
Automatic history pruning. MaxCount(n) or MaxAgeDays(n).
prune_interval
u64
100
Number of task completions between automatic prune runs.
Builder method
use taskmill::{StoreConfig,RetentionPolicy};let scheduler = Scheduler::builder().store_config(StoreConfig{max_connections:32,retention_policy:Some(RetentionPolicy::MaxCount(10_000)),prune_interval:50,
..Default::default()}).build().await?;
SamplerConfig
Controls the resource monitoring background loop.
Field
Type
Default
Description
interval
Duration
1s
How often to sample system resources.
ewma_alpha
f64
0.3
EWMA smoothing factor. Higher = more responsive to changes, lower = smoother.
Builder method
use std::time::Duration;use taskmill::SamplerConfig;let scheduler = Scheduler::builder().with_resource_monitoring().sampler_config(SamplerConfig{interval:Duration::from_millis(500),ewma_alpha:0.5,}).build().await?;
ShutdownMode
Variant
Behavior
Hard
Cancel all running tasks immediately when the scheduler stops.
Graceful(Duration)
Stop dispatching new tasks, wait for running tasks to complete (up to the timeout), then force-cancel any remaining. Stops the resource sampler afterward.
RetentionPolicy
Variant
Behavior
MaxCount(i64)
Keep the N most recent history records, prune the rest.
MaxAgeDays(i64)
Keep records from the last N days, prune older entries.
Priority constants
Constant
Value
Notes
Priority::REALTIME
0
Highest. Never throttled. Triggers preemption.
Priority::HIGH
64
Priority::NORMAL
128
Default for most tasks.
Priority::BACKGROUND
192
Priority::IDLE
255
Lowest.
Custom: Priority::new(n) for any u8 value.
Feature flags
Feature
Default
Description
sysinfo-monitor
Enabled
Cross-platform CPU and disk IO monitoring via sysinfo. Disable for mobile targets or custom samplers.