mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
For supported types, static R/W globals unsafe code can be replaced by safe `Atomic*` types. The pattern of usage is simple: - AtomicBool#swap is used to fetch the old `KEYBOARD_HOOKED` value, while setting it to true; - if the old value was true, there is effectively no change to `KEYBOARD_HOOKED`, and the flow exits from the enclosing function; - if the old value was false, execute the function (the new `KEYBOARD_HOOKED` has been set to true by swap()). The most conservative ordering is used, as the context is not performance-sensitive. Atomics are not supported on every platform, but the project assumes x86-64, which supports them.