Fix monitor flush

This commit is contained in:
Mygod
2020-08-18 04:50:51 +08:00
parent 2989094efd
commit 8a1df227c1
2 changed files with 5 additions and 4 deletions

View File

@@ -16,8 +16,7 @@ class IpLinkMonitor private constructor() : IpMonitor() {
if (monitor == null) {
monitor = IpLinkMonitor()
instance = monitor
}
monitor.flushAsync()
} else monitor.flushAsync()
}
fun unregisterCallback(owner: Any) = synchronized(this) {
if (callbacks.remove(owner) == null || callbacks.isNotEmpty()) return@synchronized

View File

@@ -28,9 +28,11 @@ class IpNeighbourMonitor private constructor() : IpMonitor() {
if (monitor == null) {
monitor = IpNeighbourMonitor()
instance = monitor
monitor.flushAsync()
null
} else monitor.neighbours.values
} else {
monitor.flushAsync()
monitor.neighbours.values
}
}?.let { callback.onIpNeighbourAvailable(it) }
fun unregisterCallback(callback: Callback) = synchronized(callbacks) {
if (callbacks.remove(callback) == null) return@synchronized