sofa-framework / sofa

Real-time multi-physics simulation with an emphasis on medical simulation.
https://www.sofa-framework.org
GNU Lesser General Public License v2.1
871 stars 297 forks source link

[Collision.Response.Contact] Make contactId thread-safe #4582

Closed fredroy closed 1 month ago

fredroy commented 2 months ago

for thread-safety, and each thread/simu would have its own pool of contact id

An other solution would be to put a guard_lock/mutex each time the ids are accessed but it would share the same pool of contact id to the whole set of thread/simu

Make the counter of ContactId atomic. A side effect is to remove the ability to restore previous contactid which was destroyed and set in a side container. I dont think we really need to save some "ids" because we will never overrun the 64 bit integer IMO (18446744073709551615 is quite big 🙃)


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

fredroy commented 2 months ago

[ci-build][with-all-tests]

hugtalbot commented 1 month ago

Error Win: ContactIdentifier.h(39): error C2492: 'sofa::component::collision::response::contact::ContactIdentifier::cpt': data with thread storage duration may not have dll interface

fredroy commented 1 month ago

[ci-build][with-all-tests]