Standard library, synchronization primitives, and undefined behavior

There is a PR for using the parking_lot code inside of libstd now: https://github.com/rust-lang/rust/pull/56410

10 Likes

If/when this PR is adopted, the Rust cheat sheet will need to be updated for Mutex<T>, since the new parking_lot code does not have a poison field. That would also be a good opportunity to add the missing RwLock<T> to the cheat sheet.

Even with that PR, Mutex will remain backwards-compatible and hence still have poison. It will just use the parking_lot machinery for implementing mutual exclusion, instead of leaving that to OS primitives.

2 Likes

I would absolutely love to update the cheat sheet if a consequence of this work is that the Box is removed. My understanding is that the Box is primarily to ensure that the OS primitive is not moved, and with parking_lot that goes away.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.