-
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.
- Loading branch information
1 parent
acd035b
commit 8f95d63
Showing
4 changed files
with
54 additions
and
45 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
25 changes: 17 additions & 8 deletions
25
...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,18 +1,27 @@ | ||
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 _bootstrapServices: List<IBootstrapService>, | ||
private val _startableServices: List<IStartableService>, | ||
private val services: ServiceProvider, | ||
) { | ||
private var coroutineScope = CoroutineScope(newSingleThreadContext(name = "ServiceProvider")) | ||
|
||
fun bootstrap() { | ||
// now that we have the params initialized, start everything else up | ||
for (bootstrapService in _bootstrapServices) | ||
for (bootstrapService in services.getAllServices<IBootstrapService>()) { | ||
bootstrapService.bootstrap() | ||
} | ||
} | ||
|
||
fun start() { | ||
// now that we have the params initialized, start everything else up | ||
for (startableService in _startableServices) | ||
startableService.start() | ||
// schedule to start all startable services in a separate thread | ||
fun scheduleStart() { | ||
coroutineScope.launch { | ||
for (service in services.getAllServices<IStartableService>()) { | ||
service.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