Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify in documentation if the C++ API is thread safe #159

Open
mkitti opened this issue May 15, 2024 · 2 comments
Open

Clarify in documentation if the C++ API is thread safe #159

mkitti opened this issue May 15, 2024 · 2 comments

Comments

@mkitti
Copy link

mkitti commented May 15, 2024

Is the the C++ API thread safe? Are there any considerations when calling tensorstore from multiple threads?

@laramiel
Copy link
Collaborator

laramiel commented May 22, 2024

The C++ api surface is quite large, however, generally speaking, tensorstore is designed to be thread-compatible at the c++ object level. So, unless otherwise marked, it's best to partition or guard tensorstore object uses when working with threads.

See, for example, the Abseil blog post on C++ types: https://abseil.io/blog/20180531-regular-types

@jbms
Copy link
Collaborator

jbms commented May 22, 2024

All const methods are thread-safe, non-const methods are not thread safe.

All const uses of a TensorStore object (which is almost all uses) are thread-safe, for example.

Most objects in TensorStore are internally reference counted and use thread-safe copy-on-write internally where needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants