kauailabs / navxmxp

Robotics Navigation Sensors. NavX-MXP designed for the National Instruments RoboRIO & FIRST FRC Robotics. Navx-MIcro designed for Android-based FIRST FTC Robots
MIT License
105 stars 88 forks source link

Java AHRS: synchronized blocks used unnecessarily? #9

Open virtuald opened 8 years ago

virtuald commented 8 years ago

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?

kauailabs commented 8 years ago

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.