As per fixme in rust_task.h, try to make this a little easier to comprehend and prove race-free, deterministic.