-
Sorry for the poor title, I'm not sure how to properly word what I'm getting at here... During the contact callbacks, I need to cache these in a list for single-threaded processing later... in the contact callback, I only do the bare minimum (i.e., set the restitution, etc), trying to keep things thread-safe. Would this be a proper use of the JPH::Mutex to ensure that adding to my cache list occurs atomically? If not, is there a way you recommend to achieve this? Listable::AddFront() simply adds an item to the front of a doubly-linked list (&interactions points to the first item in the list). I'm not married to using my Listable() class, either. If there's an atomic C++ collection that I can use instead, that is also sufficient. ` JPH::Mutex CollisionHandler::interactionMutex; ` |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Your suggested code should work and I would do it that way until a profiler tells you that you spend a lot of time waiting for |
Beta Was this translation helpful? Give feedback.
Your suggested code should work and I would do it that way until a profiler tells you that you spend a lot of time waiting for
interactionMutex
. If this is the case you can always build a lock free linked list (but I don't think it will be needed).