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) { if (monitor == null) {
monitor = IpLinkMonitor() monitor = IpLinkMonitor()
instance = monitor instance = monitor
} } else monitor.flushAsync()
monitor.flushAsync()
} }
fun unregisterCallback(owner: Any) = synchronized(this) { fun unregisterCallback(owner: Any) = synchronized(this) {
if (callbacks.remove(owner) == null || callbacks.isNotEmpty()) return@synchronized if (callbacks.remove(owner) == null || callbacks.isNotEmpty()) return@synchronized

View File

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