mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(coroutines): Use SupervisorJobs (#3714)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
0f8e475388
commit
9bf4b237dd
2 changed files with 66 additions and 47 deletions
|
|
@ -31,7 +31,7 @@ import com.geeksville.mesh.util.ignoreException
|
|||
import com.geeksville.mesh.util.toRemoteExceptions
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
|
@ -105,7 +105,7 @@ constructor(
|
|||
val mockInterfaceAddress: String by lazy { toInterfaceAddress(InterfaceId.MOCK, "") }
|
||||
|
||||
/** We recreate this scope each time we stop an interface */
|
||||
var serviceScope = CoroutineScope(Dispatchers.IO + Job())
|
||||
var serviceScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
|
||||
private var radioIf: IRadioInterface = NopInterface("")
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ constructor(
|
|||
|
||||
// cancel any old jobs and get ready for the new ones
|
||||
serviceScope.cancel("stopping interface")
|
||||
serviceScope = CoroutineScope(Dispatchers.IO + Job())
|
||||
serviceScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
|
||||
if (logSends) {
|
||||
sentPacketsLog.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue