Remove references to StaticMutex which got removed a while ago
This commit is contained in:
@@ -1281,9 +1281,7 @@ const F: &'static C = &D; // error
|
|||||||
```
|
```
|
||||||
|
|
||||||
This is because cell types do operations that are not thread-safe. Due to this,
|
This is because cell types do operations that are not thread-safe. Due to this,
|
||||||
they don't implement Sync and thus can't be placed in statics. In this
|
they don't implement Sync and thus can't be placed in statics.
|
||||||
case, `StaticMutex` would work just fine, but it isn't stable yet:
|
|
||||||
https://doc.rust-lang.org/nightly/std/sync/struct.StaticMutex.html
|
|
||||||
|
|
||||||
However, if you still wish to use these types, you can achieve this by an unsafe
|
However, if you still wish to use these types, you can achieve this by an unsafe
|
||||||
wrapper:
|
wrapper:
|
||||||
|
|||||||
@@ -31,12 +31,10 @@
|
|||||||
// initialization closure panics, the Once enters a "poisoned" state which means
|
// initialization closure panics, the Once enters a "poisoned" state which means
|
||||||
// that all future calls will immediately panic as well.
|
// that all future calls will immediately panic as well.
|
||||||
//
|
//
|
||||||
// So to implement this, one might first reach for a `StaticMutex`, but those
|
// So to implement this, one might first reach for a `Mutex`, but those cannot
|
||||||
// unfortunately need to be deallocated (e.g. call `destroy()`) to free memory
|
// be put into a `static`. It also gets a lot harder with poisoning to figure
|
||||||
// on all OSes (some of the BSDs allocate memory for mutexes). It also gets a
|
// out when the mutex needs to be deallocated because it's not after the closure
|
||||||
// lot harder with poisoning to figure out when the mutex needs to be
|
// finishes, but after the first successful closure finishes.
|
||||||
// deallocated because it's not after the closure finishes, but after the first
|
|
||||||
// successful closure finishes.
|
|
||||||
//
|
//
|
||||||
// All in all, this is instead implemented with atomics and lock-free
|
// All in all, this is instead implemented with atomics and lock-free
|
||||||
// operations! Whee! Each `Once` has one word of atomic state, and this state is
|
// operations! Whee! Each `Once` has one word of atomic state, and this state is
|
||||||
|
|||||||
@@ -49,9 +49,6 @@ impl Mutex {
|
|||||||
// references, we instead create the mutex with type
|
// references, we instead create the mutex with type
|
||||||
// PTHREAD_MUTEX_NORMAL which is guaranteed to deadlock if we try to
|
// PTHREAD_MUTEX_NORMAL which is guaranteed to deadlock if we try to
|
||||||
// re-lock it from the same thread, thus avoiding undefined behavior.
|
// re-lock it from the same thread, thus avoiding undefined behavior.
|
||||||
//
|
|
||||||
// We can't do anything for StaticMutex, but that type is deprecated
|
|
||||||
// anyways.
|
|
||||||
let mut attr: libc::pthread_mutexattr_t = mem::uninitialized();
|
let mut attr: libc::pthread_mutexattr_t = mem::uninitialized();
|
||||||
let r = libc::pthread_mutexattr_init(&mut attr);
|
let r = libc::pthread_mutexattr_init(&mut attr);
|
||||||
debug_assert_eq!(r, 0);
|
debug_assert_eq!(r, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user