←back to thread

517 points bkolobara | 1 comments | | HN request time: 0.287s | source
Show context
Spivak ◴[] No.45041771[source]
How do you encode the locking issue in the type system, it seems magical? Can you just never hold any locks when calling await, is it smart enough to know that this scheduler might move work between threads?
replies(5): >>45041806 #>>45041833 #>>45041852 #>>45041891 #>>45041898 #
1. bkolobara ◴[] No.45041891[source]
Yes, if you use a scheduler that doesn't move work between threads, it will not require the task to be Send, and the example code would compile.

Rust can use that type information and lifetimes to figure out when it's safe and when not.