navxmxp
navxmxp copied to clipboard
Java AHRS: synchronized blocks used unnecessarily?
I note that the C++ AHRS implementation doesn't use any kind of synchronization in SetYawPitchRoll
, SetAHRSPosData
, et al.
In the java implementation, each one of the set* functions have a block like..
synchronized (this) {
... set things
}
But none of the get* methods are synchronized, so the only things that are blocking each other are the update methods. Was this intentional?
Thanks for catching this; after some consideration we decided to go "lean and mean" given that writes/reads for Java native types are atomic. So the synchronized statements were removed, but we missed that part you noticed in the setXXX methods().
This will get fixed when we release the 2016 version of the navX-MXP libraries in a few days.