Specifically, lines 443-444 with lines 451-452. If the order of execution is 443,{451,452},444, then that future will never complete, right?
One solution is to use a sync_channel instead, with recv on park and send on unpark.
Naive question: I thought race conditions are not possible in Rust due to the ownership model.
Thanks for the report @critiqjo! Due to how thread unpark/park work I don't think this is actually a race. If an unpark happens before a park, it'll flag the park to immediately wake up. You can find more docs about park/unpark in the official docs.
@StefanoD in a technical sense Rust protects you from data races, not race conditions.
@StefanoD I think a better explanation is provided here. Race condition is tied to correctness of a system. It doesn't matter whether the system is just a single process, or a huge geographically distributed system. Data races is just a local phenomena that deals with concurrent memory accesses.
@alexcrichton Thanks for the clarification.
Most helpful comment
Thanks for the report @critiqjo! Due to how thread unpark/park work I don't think this is actually a race. If an unpark happens before a park, it'll flag the park to immediately wake up. You can find more docs about park/unpark in the official docs.
@StefanoD in a technical sense Rust protects you from data races, not race conditions.