4
4
5
5
Provides volatile wrapper types for raw pointers.
6
6
7
- The volatile wrapper types in this crate wrap a pointer to any [ ` Copy ` ] -able type and provide volatile memory access to wrapped value.
7
+ The volatile wrapper types in this crate wrap a pointer to any ` Copy ` -able type and provide volatile memory access to wrapped value.
8
8
Volatile memory accesses are never optimized away by the compiler, and are useful in many low-level systems programming and concurrent contexts.
9
9
10
- This crate provides two different wrapper types: [ ` VolatilePtr ` ] and [ ` VolatileRef ` ] .
10
+ This crate provides two different wrapper types: ` VolatilePtr ` and ` VolatileRef ` .
11
11
The difference between the two types is that the former behaves like a raw pointer, while the latter behaves like a Rust reference type.
12
12
For example, ` VolatilePtr ` can be freely copied, but not sent across threads because this could introduce mutable aliasing.
13
13
The ` VolatileRef ` type, on the other hand, requires exclusive access for mutation, so that sharing it across thread boundaries is safe.
@@ -17,7 +17,7 @@ Both wrapper types *do not* enforce any atomicity guarantees; to also get atomic
17
17
## Why is there no ` VolatileCell ` ?
18
18
19
19
Many people expressed interest in a ` VolatileCell ` type, i.e. a transparent wrapper type that owns the wrapped value.
20
- Such a type would be similar to [ ` core::cell::Cell ` ] , with the difference that all methods are volatile.
20
+ Such a type would be similar to ` core::cell::Cell ` , with the difference that all methods are volatile.
21
21
Unfortunately, it is not sound to implement such a ` VolatileCell ` type in Rust.
22
22
The reason is that Rust and LLVM consider ` & ` and ` &mut ` references as _ dereferencable_ .
23
23
This means that the compiler is allowed to freely access the referenced value without any restrictions.
0 commit comments