I’m trying to implement the following system:
- A top level Activity is given a set of Jobs, which are arbitrary logic to run.
- When the top level activity is called, it runs the jobs which can be in parallel — they should not depend on each other.
- While the jobs are running, the activity polls them regularly (e.g. every 100 ms) to check their current state.
- There are a set of Views which display application state. These views should be updated with the state of the jobs each time the activity wakes up.
I was intending for the job state to contain mutable information, like number of units complete, or description of “what it is doing now”.
Is it possible / a good candidate to implement this with
futures-rs? The API doesn’t look like it supports passing an updatable state of the job to the caller (either using
I guess an ideal mechanism is whenever the Job/Future/Task-like-thing is
polled, it can return
Result<Async::NotReady<State, ()>, or an error, so that there isn’t a need for an
Arc<Mutex<State>> somewhere, if that is possible.