mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Support immediate notify of connection listener.
Also only perform immediate notification to the callback actually requesting the notification, not all existing callbacks. Offset returned uids by 1 so uid=0 can be used to indicate immediate notification.
This commit is contained in:
@@ -70,7 +70,7 @@ unsigned int AddEntryListener(StringRef prefix, EntryListenerCallback callback,
|
||||
Notifier& notifier = Notifier::GetInstance();
|
||||
unsigned int uid = notifier.AddEntryListener(prefix, callback);
|
||||
notifier.Start();
|
||||
if (immediate_notify) Storage::GetInstance().NotifyEntries(prefix);
|
||||
if (immediate_notify) Storage::GetInstance().NotifyEntries(prefix, callback);
|
||||
return uid;
|
||||
}
|
||||
|
||||
@@ -78,10 +78,12 @@ void RemoveEntryListener(unsigned int entry_listener_uid) {
|
||||
Notifier::GetInstance().RemoveEntryListener(entry_listener_uid);
|
||||
}
|
||||
|
||||
unsigned int AddConnectionListener(ConnectionListenerCallback callback) {
|
||||
unsigned int AddConnectionListener(ConnectionListenerCallback callback,
|
||||
bool immediate_notify) {
|
||||
Notifier& notifier = Notifier::GetInstance();
|
||||
unsigned int uid = notifier.AddConnectionListener(callback);
|
||||
Notifier::GetInstance().Start();
|
||||
if (immediate_notify) Dispatcher::GetInstance().NotifyConnections(callback);
|
||||
return uid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user