navxmxp icon indicating copy to clipboard operation
navxmxp copied to clipboard

Java AHRS: synchronized blocks used unnecessarily?

Open virtuald opened this issue 8 years ago • 1 comments

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?

virtuald avatar Jan 03 '16 03:01 virtuald

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.

kauailabs avatar Jan 07 '16 05:01 kauailabs