Right now run_on_state_changes only does the right thing if the RunLoop is the top-level task. If it's being joined with another future it might be re-run unnecessarily.
One option to fix this would be to wrap the state change waker in a layer that also notifies the RunLoop that a state change did occur. Maybe by adding a "state revision" field to the runtime and incrementing that on updates? Then we could make sure the state revision has advanced past the runtime revision when calling run_once.
I'm not sure whether the run skipping should be done in RunTime or RunLoop, I'm leaning towards the latter.
Right now
run_on_state_changes
only does the right thing if the RunLoop is the top-level task. If it's beingjoin
ed with another future it might be re-run unnecessarily.One option to fix this would be to wrap the state change waker in a layer that also notifies the RunLoop that a state change did occur. Maybe by adding a "state revision" field to the runtime and incrementing that on updates? Then we could make sure the state revision has advanced past the runtime revision when calling
run_once
.I'm not sure whether the run skipping should be done in RunTime or RunLoop, I'm leaning towards the latter.