You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I wanted to create a bot via some algorithm outside the behaviour-tree code, can I assume that methods like entity_manager->GetLocalPlayer()->SetPosition() and entity_manager->GetLocalPlayer()->GetPosition() and such are thread safe? I mean I know there's a GetMutex in LocalPlayer, if I acquire/release that, am I good to go?
regards
p.s. having lots of fun with your library! very easy to work with.
Short answer: yes, if you lock the mutex of the object you're using, you will (should) be fine. Examples for world, local_player and entity_manager.
Long answer: the thread safety thing is quite old and I'd like to work on it someday (at least add some comments to the functions so it's clear that you should or not lock the corresponding mutex before calling it). It's nevertheless safe in the sense that all library internal calls lock the mutexes before doing stuff. However, it's not obvious when you should lock or not. For example, the EntityManger::AddEntity function already lock the mutex on its own (you shouldn't have to call this function except if you do something really exotic). Similarly, a few functions return copies of the objects so you can unlock the mutex as soon as you get the object, but some other return pointers/references, forcing you to keep the mutex locked while you're using it.
Repository owner locked and limited conversation to collaborators on Feb 9, 2022
Activity
adepierre commentedon Feb 9, 2022
Short answer: yes, if you lock the mutex of the object you're using, you will (should) be fine. Examples for world, local_player and entity_manager.
Long answer: the thread safety thing is quite old and I'd like to work on it someday (at least add some comments to the functions so it's clear that you should or not lock the corresponding mutex before calling it). It's nevertheless safe in the sense that all library internal calls lock the mutexes before doing stuff. However, it's not obvious when you should lock or not. For example, the
EntityManger::AddEntityfunction already lock the mutex on its own (you shouldn't have to call this function except if you do something really exotic). Similarly, a few functions return copies of the objects so you can unlock the mutex as soon as you get the object, but some other return pointers/references, forcing you to keep the mutex locked while you're using it.