mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Make Java AnalogGyro.getAngle() thread-safe.
In the Java implementation, "result" is an instance variable (to avoid needing to perform a memory allocation on each call to getAngle). However, this means that calls to getAngle() from multiple threads can step on each other. Synchronize the method to avoid this issue. Reported by: Jackson Gray (http://www.chiefdelphi.com/forums/showthread.php?threadid=145124) Note this does not synchronize accesses between configuration methods such as calibrate() and accessor methods such as getAngle(). Change-Id: I9ecc962d4fba66f6134fd801cfd607f155b41fe5
This commit is contained in:
committed by
Peter Johnson (294)
parent
ec13d00b18
commit
fa8b68419f
@@ -165,7 +165,7 @@ public class AnalogGyro extends GyroBase implements Gyro, PIDSource, LiveWindowS
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public double getAngle() {
|
||||
public synchronized double getAngle() {
|
||||
if (m_analog == null) {
|
||||
return 0.0;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user