perf(monitors): 复用网络接口元数据并一致读取路径状态

This commit is contained in:
2026-11-16 00:06:03 +08:00
parent 4b8deb2e48
commit 97c1bc3b7f
5 changed files with 45 additions and 24 deletions
+2 -8
View File
@@ -29,16 +29,10 @@ nonisolated final class NetworkPathObserver: @unchecked Sendable {
monitor.start(queue: DispatchQueue(label: "cn.airnan.kymo.network-path"))
}
func snapshot() -> NetworkPathStatus? {
func snapshot() -> (status: NetworkPathStatus?, primaryInterface: String?) {
lock.lock()
defer { lock.unlock() }
return status
}
func defaultInterface() -> String? {
lock.lock()
defer { lock.unlock() }
return primaryInterface
return (status, primaryInterface)
}
deinit { monitor.cancel() }