tensorstore icon indicating copy to clipboard operation
tensorstore copied to clipboard

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

Open mkitti opened this issue 1 year ago • 2 comments

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

mkitti avatar May 15 '24 18:05 mkitti

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

laramiel avatar May 22 '24 18:05 laramiel

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.

jbms avatar May 22 '24 19:05 jbms