mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[ntcore] Revamp listeners (#4511)
- In both C++ and Java, add listener functions to Instance class (same as NT3 provided) - Add WaitForListenerQueue functions (same as NT3 provided) - Move Java non-poller implementation to Instance (previously only handled single instance) - Change C++ listeners to take non-const references for subscribers etc to help avoid footguns from use of temporary objects (also add doc comment) - Fix Preferences making .type persistent
This commit is contained in:
@@ -13,6 +13,7 @@ import edu.wpi.first.networktables.NetworkTable;
|
||||
import edu.wpi.first.networktables.NetworkTableEntry;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import edu.wpi.first.networktables.StringPublisher;
|
||||
import edu.wpi.first.networktables.Topic;
|
||||
import edu.wpi.first.networktables.TopicListener;
|
||||
import edu.wpi.first.networktables.TopicListenerFlags;
|
||||
import java.util.Collection;
|
||||
@@ -75,10 +76,14 @@ public final class Preferences {
|
||||
}
|
||||
m_listener =
|
||||
new TopicListener(
|
||||
m_table.getInstance(),
|
||||
new String[] {m_table.getPath() + "/"},
|
||||
m_tableSubscriber,
|
||||
TopicListenerFlags.kImmediate | TopicListenerFlags.kPublish,
|
||||
event -> event.info.getTopic().setPersistent(true));
|
||||
event -> {
|
||||
Topic topic = event.info.getTopic();
|
||||
if (!topic.equals(m_typePublisher.getTopic())) {
|
||||
event.info.getTopic().setPersistent(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user