google / google/rust_icu

Thread safety

Open
#209 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
140
Forks
34
Avg merge
5h 5m
Merged PRs (30d)
4

Description

According to https://unicode-org.github.io/icu/userguide/icu/design.html#thread-safe-const-apis, using the methods that take a const this pointer is thread safe.

In my case I'd like to use UCollator across multiple threads, which should be safe since `ucol_strcoll` takes a const pointer, but I can't because it's not Sync+Send. I've looked at the source of rust_icu_ucol, and all the methods that take a non-const pointer in C are `&mut self` in Rust, except for `set_attribute`, which is generated by the `generalized_fallible_setter` macro. If `generalized_fallible_setter` is fixed to generate `&mut self`, would it be safe to mark UCollator (and other service objects, assuming the same is true for their methods) as Sync (edit: and Send)?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.