| Crates.io | potassium |
| lib.rs | potassium |
| version | 0.4.2 |
| created_at | 2025-12-12 23:53:15.958233+00 |
| updated_at | 2026-01-15 13:01:45.611842+00 |
| description | A lean and mean job scheduler |
| homepage | |
| repository | https://github.com/cohaereo/potassium |
| max_upload_size | |
| id | 1982376 |
| size | 115,293 |
Potassium is a job scheduler for modern multi-threaded game engines.
It is designed so that the entire engine can be built around it in order to maximize CPU utilization.
use potassium::{Scheduler, Priority};
let scheduler = Scheduler::default();
println!("Running with {} workers", scheduler.num_workers());
let long_job = scheduler
.job_builder("long_job")
.priority(Priority::Low)
.spawn_with_result(|| {
let start = std::time::Instant::now();
std::thread::sleep(std::time::Duration::from_secs(2));
let duration = start.elapsed();
println!("Long job completed.");
duration
});
let job1 = scheduler
.job_builder("job1")
.priority(Priority::High)
.spawn(|| {
// Doing some hard work
std::thread::sleep(std::time::Duration::from_millis(200));
});
let job2 = scheduler
.job_builder("job2")
.priority(Priority::Medium)
.spawn(|| {
// Doing some medium work
std::thread::sleep(std::time::Duration::from_millis(300));
});
let job_sync = scheduler
.job_builder("sync_job")
.priority(Priority::Medium)
.dependencies(vec![job1, job2])
.spawn(|| {
println!("All small jobs completed. Running sync job.");
});
// Jobs can be awaited using the returned JobHandle
job_sync.wait();
println!("Small job sync completed. Big job should finish shortly.");
let long_job_duration = long_job.wait();
println!(
"Long job took {:.2?} seconds",
long_job_duration.as_secs_f32()
);
scheduler.wait_for_all();
println!("All jobs completed.");