May I ask a small question? Many cross-platform system APIs, such as futex, have already been implemented in the Rust standard library. But why aren't they made public? Currently, they are only used privately within the standard library. The source in mod sys
if I would like to use the futex, I have to include another third-part crate. So, what considerations led to that decision?
Stability.
As @nerditation already said std::sync::Mutex is the stable public API. And Rust promises to keep that API. How it is implemented can change though, and Rust does not want to stabilize all these implementation details with a vast API.
thank all, I asked this, because I want to use the lower level api about futex to impl something myself, and here std::sync::Mutex is too heavy to use. I add a binding crate for this(system api), which seems unnecessary when I found the std already impl them. So I was just a little confused.
futex is especially cursed because even in C, there's no futex call. You have to use syscall(SYS_futex, ...) and the number of arguments depends on the op. The good news is that it is not hard to wrap the specific calls you want to do in Rust.