| Crates.io | dropbear_future-queue |
| lib.rs | dropbear_future-queue |
| version | 0.1.2 |
| created_at | 2025-09-20 15:22:54.066903+00 |
| updated_at | 2025-09-24 04:40:09.693929+00 |
| description | A queue for polling futures in a synchronous context |
| homepage | |
| repository | https://github.com/4tkbytes/dropbear |
| max_upload_size | |
| id | 1847868 |
| size | 31,785 |
A helper queue for polling futures in single threaded systems such as in winit.
// create new queue
let queue = FutureQueue::new();
// create a new handle to keep for reference
let handle = queue.push(async move {
tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;
67 + 41
});
// check initial status
assert!(matches!(queue.get_status(&handle), Some(FutureStatus::NotPolled)));
// execute the futures
queue.poll();
// wait for the task to do its job (this can be simulated with an update loop)
tokio::time::sleep(tokio::time::Duration::from_millis(20)).await;
// check the result
if let Some(result) = queue.exchange_as::<i32>(&handle) {
println!("67 + 41 = {}", result);
assert_eq!(result, 108);
}