-
Notifications
You must be signed in to change notification settings - Fork 313
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
Is this library thread safe? #3
Comments
Unless otherwise documented, all S2 classes have the same thread-safety properties as std::vector: const methods are thread-safe, and non-const methods are not thread-safe. So for example you issue multiple queries at the same time, but updates to the index cannot overlap any other operations. |
This is documented on // Locking is used to ensure that MutableS2ShapeIndex
// has the same thread-safety properties as "vector": const methods are
// thread-safe, while non-const methods are not thread-safe. This means that
// if one thread updates the index, you must ensure that no other thread is
// reading or updating the index at the same time. @ericveach Should we add something similar on |
Probably. Of course someone could write an S2ShapeIndex subtype with
different thread safety properties if desired, but there doesn't seem to be
any harm in documenting that the abstract method is not required to be
thread-safe.
…On Wed, Jan 17, 2018 at 2:10 PM, Jesse Rosenstock ***@***.***> wrote:
This is documented on `MutableS2ShapeIndex'
<https://github.com/google/s2geometry/blob/8a8746c7f4d4c53e8561e78e6ca380e8d4a0b9d3/src/s2/mutable_s2shape_index.h#L104>
:
// Locking is used to ensure that MutableS2ShapeIndex// has the same thread-safety properties as "vector": const methods are// thread-safe, while non-const methods are not thread-safe. This means that// if one thread updates the index, you must ensure that no other thread is// reading or updating the index at the same time.
@ericveach <https://github.com/ericveach> Should we add something similar
on S2ShapeIndex? The Minimize() comment
<https://github.com/google/s2geometry/blob/8a8746c7f4d4c53e8561e78e6ca380e8d4a0b9d3/src/s2/s2shape_index.h#L256>
implies this, but it's easy to miss.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AgRtitXoJYVHKC1ZwLDXZPcQ5NrCkWMuks5tLm_FgaJpZM4Rfrmm>
.
|
Now documented on |
Is S2PointIndex thread safe? Should I use mutex when S2PointIndex.Add() and S2ClosestPointQuery.query() are called simultaneously in multithread?
The text was updated successfully, but these errors were encountered: