xkbcommon / libxkbcommon

keymap handling library for toolkits and window systems
https://xkbcommon.org
Other
286 stars 125 forks source link

Make keymap thread-safe #540

Open wismill opened 1 week ago

wismill commented 1 week ago

(WIP, to open discussion)

The only value that can be modified, once the keymap is compiled, is the reference counter. Use atomics to make it thread-safe.

WARNING: this alone does not make the keymap API thread-safe:

  1. It depends on the atom table in the xkb_context for its strings values; this table is not thread-safe. However it is “safe” only if no other keymap is compiled using the same context.
  2. Functions retrieving text may use the xkb_context internal string buffer, which is not thread safe. API not using this buffer should be “safe”.
  3. Functions use the xkb_context log function, but modifying it is not thread-safe.
  4. State API is not thread-safe.

Fixes #300