File tree 3 files changed +5
-12
lines changed
3 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -1281,9 +1281,7 @@ const F: &'static C = &D; // error
1281
1281
```
1282
1282
1283
1283
This is because cell types do operations that are not thread-safe. Due to this,
1284
- they don't implement Sync and thus can't be placed in statics. In this
1285
- case, `StaticMutex` would work just fine, but it isn't stable yet:
1286
- https://doc.rust-lang.org/nightly/std/sync/struct.StaticMutex.html
1284
+ they don't implement Sync and thus can't be placed in statics.
1287
1285
1288
1286
However, if you still wish to use these types, you can achieve this by an unsafe
1289
1287
wrapper:
Original file line number Diff line number Diff line change 31
31
// initialization closure panics, the Once enters a "poisoned" state which means
32
32
// that all future calls will immediately panic as well.
33
33
//
34
- // So to implement this, one might first reach for a `StaticMutex`, but those
35
- // unfortunately need to be deallocated (e.g. call `destroy()`) to free memory
36
- // on all OSes (some of the BSDs allocate memory for mutexes). It also gets a
37
- // lot harder with poisoning to figure out when the mutex needs to be
38
- // deallocated because it's not after the closure finishes, but after the first
39
- // successful closure finishes.
34
+ // So to implement this, one might first reach for a `Mutex`, but those cannot
35
+ // be put into a `static`. It also gets a lot harder with poisoning to figure
36
+ // out when the mutex needs to be deallocated because it's not after the closure
37
+ // finishes, but after the first successful closure finishes.
40
38
//
41
39
// All in all, this is instead implemented with atomics and lock-free
42
40
// operations! Whee! Each `Once` has one word of atomic state, and this state is
Original file line number Diff line number Diff line change @@ -49,9 +49,6 @@ impl Mutex {
49
49
// references, we instead create the mutex with type
50
50
// PTHREAD_MUTEX_NORMAL which is guaranteed to deadlock if we try to
51
51
// re-lock it from the same thread, thus avoiding undefined behavior.
52
- //
53
- // We can't do anything for StaticMutex, but that type is deprecated
54
- // anyways.
55
52
let mut attr: libc:: pthread_mutexattr_t = mem:: uninitialized ( ) ;
56
53
let r = libc:: pthread_mutexattr_init ( & mut attr) ;
57
54
debug_assert_eq ! ( r, 0 ) ;
You can’t perform that action at this time.
0 commit comments