Highlight differences of async_std::sync::Mutex and std::sync::Mutex in the docs
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 339
- PR merge metrics
- No merged PRs in 30d
Description
I have the following question regarding async_std::sync::Mutex and thought it might be a good addition to clarify it in the docs (if my question is valid / I am new to Rust).
Can the async_std::sync::Mutex be used in a single thread to synchronise a sequence of awaits? For example:
```
async fn read_at(pos) {
// make sure concurrent calls to test read at the correct position
let file = file_mutex.lock().await;
file.seek(pos).await;
file.read(...).await;
}
```
The std::sync::Mutex docs say `lock()` may panic when already locked from the same thread. However, for single threaded async/await code it may make sense to allow this.
If this is not possible is there a lock with this behaviour?
Contributor guide
Assessment
This issue has not been assessed yet.