rust/library/std/src
Jonas Schievink a835af174c
Rollup merge of #76932 - fusion-engineering-forks:condvar-promise, r=sfackler
Relax promises about condition variable.

For quite a while now, there have been plans to at some point use parking_lot or some other more efficient implementation of mutexes and condition variables. Right now, Mutex and CondVar both Box the 'real' mutex/condvar inside, to give it a stable address. This was done because implementations like pthread and Windows critical sections may not be moved. More efficient implementations based on futexes, WaitOnAddress, Windows SRW locks, parking_lot, etc. may be moved (while not borrowed), so wouldn't need boxing.

However, not boxing them (which would be great goal to achieve), breaks a promise std currently makes about CondVar. CondVar promises to panic when used with different mutexes, to ensure consistent behaviour on all platforms. To this check, a mutex is considered 'the same' if the address of the 'real mutex' in the Box is the same. This address doesn't change when moving a `std::mutex::Mutex` object, effectively giving it an identity that survives moves of the Mutex object. If we ever switch to a non-boxed version, they no longer carry such an identity, and this check can no longer be made.

Four options:
1. Always box mutexes.
2. Add a `MutexId` similar to `ThreadId`. Making mutexes bigger, and making it hard to ever have a `const fn new` for them.
3. Making the requirement of CondVar stricter: panic if the Mutex object itself moved.
4. Making the promise of CondVar weaker: don't promise to panic.

1, 2, and 3 seem like bad options. This PR updates the documentation for 4.
2020-09-25 19:42:28 +02:00
..
backtrace std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
collections Rollup merge of #76887 - GuillaumeGomez:hashset-iter-types-examples, r=Dylan-DPC 2020-09-20 15:51:59 +02:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f32 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f64 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
ffi Capitalize safety comments 2020-09-08 22:26:44 -04:00
fs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
io Rollup merge of #76275 - FedericoPonzi:immutable-write-impl-73836, r=dtolnay 2020-09-21 20:40:44 -07:00
lazy std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
memchr std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
net Rollup merge of #76304 - CDirkx:const-ip, r=ecstatic-morse 2020-09-25 02:29:30 +02:00
num std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
os library/std: raw: Add support for RISC-V 32-bit 2020-09-16 08:44:35 -07:00
path std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
prelude Fix incorrect link in prelude 2020-09-02 17:38:21 -04:00
process std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
sync Rollup merge of #76932 - fusion-engineering-forks:condvar-promise, r=sfackler 2020-09-25 19:42:28 +02:00
sys Revert "Function to convert OpenOptions to c_int" 2020-09-22 23:07:30 -04:00
sys_common Rollup merge of #77164 - fusion-engineering-forks:no-more-funny-underscores, r=Mark-Simulacrum 2020-09-25 02:29:51 +02:00
thread Update library functions with stability attributes 2020-09-22 10:05:58 -07:00
time std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
alloc.rs a few more &mut self -> self changes 2020-09-22 21:04:31 -07:00
ascii.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
backtrace.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
env.rs Improve docs for std::env::args() 2020-09-04 14:00:09 -07:00
error.rs Mark Error impl for LayoutErr as stable. 2020-09-11 13:36:15 +02:00
f32.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f64.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
fs.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
future.rs Fix stabilization marker for future_readiness_fns 2020-09-15 23:12:08 +02:00
keyword_docs.rs Improve wording for const pointers 2020-09-01 19:44:20 -07:00
lazy.rs Simplify SyncOnceCell's take and drop. 2020-09-12 14:00:38 +02:00
lib.rs Make delegation methods of std::net::IpAddr unstable const 2020-09-23 21:33:39 +02:00
macros.rs Add missing links 2020-08-22 20:23:50 -07:00
memchr.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
num.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
panic.rs Mark RefUnwindSafe impls for stable atomic types as stable. 2020-09-11 13:36:15 +02:00
panicking.rs Abort when catch_unwind catches a foreign exception 2020-08-27 21:08:30 +01:00
path.rs Rollup merge of #73963 - hellow554:unsafe_path, r=Mark-Simulacrum 2020-09-19 11:47:31 +02:00
primitive_docs.rs Rollup merge of #76164 - lzutao:slice-array, r=ehuss 2020-09-03 02:22:04 +02:00
process.rs Rollup merge of #76275 - FedericoPonzi:immutable-write-impl-73836, r=dtolnay 2020-09-21 20:40:44 -07:00
rt.rs Prevent __rust_begin_short_backtrace frames from being tail-call optimised away 2020-08-07 19:31:25 +01:00
time.rs Rollup merge of #76162 - abrausch:documentation-fix-duration_since, r=jyn514 2020-09-09 01:35:10 +02:00