-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2141 from OneSignal/rollback-init-optimization
Revert "Merge pull request #2127 from OneSignal/get-service-by-getter"
- Loading branch information
Showing
5 changed files
with
67 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 9 additions & 14 deletions
23
...nalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/startup/StartupService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
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 _bootstrapServices: List<IBootstrapService>, | ||
private val _startableServices: List<IStartableService>, | ||
) { | ||
private val coroutineScope = CoroutineScope(newSingleThreadContext(name = "StartupService")) | ||
|
||
fun bootstrap() { | ||
services.getAllServices<IBootstrapService>().forEach { it.bootstrap() } | ||
// now that we have the params initialized, start everything else up | ||
for (bootstrapService in _bootstrapServices) | ||
bootstrapService.bootstrap() | ||
} | ||
|
||
// schedule to start all startable services in a separate thread | ||
fun scheduleStart() { | ||
coroutineScope.launch { | ||
services.getAllServices<IStartableService>().forEach { it.start() } | ||
} | ||
fun start() { | ||
// now that we have the params initialized, start everything else up | ||
for (startableService in _startableServices) | ||
startableService.start() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters