rust/library/std/src
Mara Bos 6f6336b4a1 Split sys_common::Mutex in StaticMutex and MovableMutex.
The (unsafe) Mutex from sys_common had a rather complicated interface.
You were supposed to call init() manually, unless you could guarantee it
was neither moved nor used reentrantly.

Calling `destroy()` was also optional, although it was unclear if 1)
resources might be leaked or not, and 2) if destroy() should only be
called when `init()` was called.

This allowed for a number of interesting (confusing?) different ways to
use this Mutex, all captured in a single type.

In practice, this type was only ever used in two ways:

1. As a static variable. In this case, neither init() nor destroy() are
   called. The variable is never moved, and it is never used
   reentrantly. It is only ever locked using the LockGuard, never with
   raw_lock.

2. As a Boxed variable. In this case, both init() and destroy() are
   called, it will be moved and possibly used reentrantly.

No other combinations are used anywhere in `std`.

This change simplifies things by splitting this Mutex type into
two types matching the two use cases: StaticMutex and MovableMutex.

The interface of both new types is now both safer and simpler. The first
one does not call nor expose init/destroy, and the second one calls
those automatically in its new() and Drop functions. Also, the locking
functions of MovableMutex are no longer unsafe.
2020-09-27 10:05:56 +02:00
..
backtrace std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
collections Rollup merge of #76917 - GuillaumeGomez:map-missing-code-examples, r=Dylan-DPC 2020-09-27 01:53:13 +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 Implement destructuring for all aggregates and for references 2020-09-20 13:28:18 +02:00
fs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
io Auto merge of #77154 - fusion-engineering-forks:lazy-stdio, r=dtolnay 2020-09-27 04:50:46 +00: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 Split sys_common::Mutex in StaticMutex and MovableMutex. 2020-09-27 10:05:56 +02:00
sys Split sys_common::Mutex in StaticMutex and MovableMutex. 2020-09-27 10:05:56 +02:00
sys_common Split sys_common::Mutex in StaticMutex and MovableMutex. 2020-09-27 10:05:56 +02:00
thread Split sys_common::Mutex in StaticMutex and MovableMutex. 2020-09-27 10:05:56 +02: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 Add new feature gate to standard library 2020-09-25 10:38:21 -07: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 Add doc alias for pointer primitive 2020-09-26 11:21:24 +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 Split sys_common::Mutex in StaticMutex and MovableMutex. 2020-09-27 10:05:56 +02:00