unicode-org / icu4x

Solving i18n for client-side and resource-constrained environments.
https://icu4x.unicode.org
Other
1.38k stars 176 forks source link

Document multithreading constraints on ICU4X-backed hb_unicode_funcs_t for HarfBuzz #2838

Open hsivonen opened 1 year ago

hsivonen commented 1 year ago

hb_unicode_funcs_t marked immutable has HarfBuzz-provided atomic refcounting for multithreaded use. Also, the ICU4X data structures themselves that are held within DataPayload should be fine to read from multiple threads (even if not marked so on the Rust level). It's unclear to me, though, if DataPayload is OK to allocate on one thread and free on another thread unless it's been compiled with the sync option.

We should document the multithreading constraints (or the absence of constraints) that apply to hb_unicode_funcs_t set up by icu_harfbuzz.

sffc commented 1 year ago

@hsivonen I'm assigning this to you but I'm willing to be the reviewer.

sffc commented 1 year ago

It's unclear to me, though, if DataPayload is OK to allocate on one thread and free on another thread unless it's been compiled with the sync option.

DataPayload has a non-atomic Rc inside by default, which becomes Arc if compiled with the sync feature.