mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpilib] Fix deadlocks in Mechanism2d et al. (#3770)
UpdateEntries() and Flush() are called from methods that lock the mutex, so locking it again will cause deadlocks. This also updates the Java code to make MechanismObject2d::update synchronized like in the C++ version.
This commit is contained in:
committed by
GitHub
parent
acb64dff97
commit
d81ef2bc5c
@@ -128,7 +128,7 @@ public class MechanismLigament2d extends MechanismObject2d {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void updateEntries(NetworkTable table) {
|
||||
protected void updateEntries(NetworkTable table) {
|
||||
table.getEntry(".type").setString("line");
|
||||
m_angleEntry = table.getEntry("angle");
|
||||
m_lengthEntry = table.getEntry("length");
|
||||
@@ -138,7 +138,7 @@ public class MechanismLigament2d extends MechanismObject2d {
|
||||
}
|
||||
|
||||
/** Flush latest data to NT. */
|
||||
private synchronized void flush() {
|
||||
private void flush() {
|
||||
if (m_angleEntry != null) {
|
||||
m_angleEntry.setDouble(m_angle);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class MechanismObject2d {
|
||||
return object;
|
||||
}
|
||||
|
||||
final void update(NetworkTable table) {
|
||||
final synchronized void update(NetworkTable table) {
|
||||
m_table = table;
|
||||
updateEntries(m_table);
|
||||
for (MechanismObject2d obj : m_objects.values()) {
|
||||
|
||||
@@ -86,7 +86,7 @@ public final class MechanismRoot2d {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
private synchronized void flush() {
|
||||
private void flush() {
|
||||
if (m_xEntry != null) {
|
||||
m_xEntry.setDouble(m_x);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user