Skip to content

Commit

Permalink
use thread instead of coroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
jinliu9508 committed Jul 26, 2024
1 parent a7602dc commit b432a80
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package com.onesignal.core.internal.startup

import com.onesignal.common.services.ServiceProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.newSingleThreadContext

internal class StartupService(
private val services: ServiceProvider,
) {
private val coroutineScope = CoroutineScope(newSingleThreadContext(name = "StartupService"))

fun bootstrap() {
services.getAllServices<IBootstrapService>().forEach { it.bootstrap() }
}

// schedule to start all startable services in a separate thread
fun scheduleStart() {
coroutineScope.launch {
Thread {
services.getAllServices<IStartableService>().forEach { it.start() }
}
}
Expand Down

0 comments on commit b432a80

Please sign in to comment.