local-pool-with-id
A minor variation on a LocalPool executor which exposes unique IDs for tracking future completion.
This should almost be a drop in replacement for the existing LocalPool. All existing traits are still implemented. There are two API differences:
- New
(Local)SpawnWithId
traits have been implemented. These accept the same arguments as their non-ID counterparts but return a unique ID that can be used to identify whether a spawned future has been completed. try_run_one
now returns anOption<usize>
instead of a boolean. This usize will correspond to the ID received from the previous APIs and can be used with external tracking mechanism to know if a future is complete.
Example
let mut spawned_ids = new;
let mut pool = new;
let spawner = pool.spawner;
let = spawner
.spawn_with_handle
.unwrap;
let = spawner
.spawn_with_handle
.unwrap;
spawned_ids.insert;
spawned_ids.insert;
while !spawned_ids.is_empty
assert_eq!;
assert_eq!;