You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, AIUI this code is incorrect as soon as a mutable reference is created to the static variable, as the lack of synchronization means that the mutable reference may alias.
This means that mutable statics can only be used when you already have some method of synchronization in place. Unfortunately this makes mutable statics quite useless. For example: a typical use of a mutable static might be to store a libc::sem_t semaphore type.
The text was updated successfully, but these errors were encountered:
However, AIUI this code is incorrect as soon as a mutable reference is created to the static variable, as the lack of synchronization means that the mutable reference may alias.
Hm, yeah that code should probably use &raw mut instead of &mut (Cc rust-lang/rust#73394).
The documentation gives an example of "correct" usage of a mutable static, where a hypothetical "atomic_add" function is called.
https://doc.rust-lang.org/reference/items/static-items.html#mutable-statics
However, AIUI this code is incorrect as soon as a mutable reference is created to the static variable, as the lack of synchronization means that the mutable reference may alias.
This means that mutable statics can only be used when you already have some method of synchronization in place. Unfortunately this makes mutable statics quite useless. For example: a typical use of a mutable static might be to store a
libc::sem_t
semaphore type.The text was updated successfully, but these errors were encountered: