mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: replace MutableList with CopyOnWriteArrayList
This commit is contained in:
parent
9190a6dcab
commit
5a1b355b66
1 changed files with 2 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.mapLatest
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
|
|
@ -25,7 +26,7 @@ private fun NsdManager.discoverServices(
|
|||
serviceType: String,
|
||||
protocolType: Int = NsdManager.PROTOCOL_DNS_SD,
|
||||
): Flow<List<NsdServiceInfo>> = callbackFlow {
|
||||
val serviceList = mutableListOf<NsdServiceInfo>()
|
||||
val serviceList = CopyOnWriteArrayList<NsdServiceInfo>()
|
||||
val discoveryListener = object : NsdManager.DiscoveryListener {
|
||||
override fun onStartDiscoveryFailed(serviceType: String, errorCode: Int) {
|
||||
cancel("Start Discovery failed: Error code: $errorCode")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue