Skip to content

Commit 288eeb3

Browse files
committed
bug fix
1 parent 07bdd5c commit 288eeb3

File tree

1 file changed

+8
-6
lines changed
  • core/src/main/java/com/segment/analytics/kotlin/core

1 file changed

+8
-6
lines changed

core/src/main/java/com/segment/analytics/kotlin/core/Waiting.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,36 @@ interface WaitingPlugin: Plugin {
2727
}
2828
}
2929

30-
fun Analytics.pauseEventProcessing(plugin: WaitingPlugin) = analyticsScope.launch {
30+
fun Analytics.pauseEventProcessing(plugin: WaitingPlugin) = analyticsScope.launch(analyticsDispatcher) {
3131
store.dispatch(System.AddWaitingPlugin(plugin.hashCode()), System::class)
32+
pauseEventProcessing()
3233
}
3334

3435

35-
fun Analytics.resumeEventProcessing(plugin: WaitingPlugin) = analyticsScope.launch {
36+
fun Analytics.resumeEventProcessing(plugin: WaitingPlugin) = analyticsScope.launch(analyticsDispatcher) {
3637
store.dispatch(System.RemoveWaitingPlugin(plugin.hashCode()), System::class)
38+
resumeEventProcessing()
3739
}
3840

3941
internal suspend fun Analytics.running(): Boolean {
4042
val system = store.currentState(System::class)
4143
return system?.running ?: false
4244
}
4345

44-
internal suspend fun Analytics.pauseEventProcessing() {
46+
internal suspend fun Analytics.pauseEventProcessing(timeout: Long = 30_000) {
4547
if (!running()) return
4648

4749
store.dispatch(System.ToggleRunningAction(false), System::class)
48-
startProcessingAfterTimeout()
50+
startProcessingAfterTimeout(timeout)
4951
}
5052

5153
internal suspend fun Analytics.resumeEventProcessing() {
5254
if (running()) return
5355
store.dispatch(System.ToggleRunningAction(true), System::class)
5456
}
5557

56-
internal fun Analytics.startProcessingAfterTimeout() = analyticsScope.launch {
57-
delay(30_000)
58+
internal fun Analytics.startProcessingAfterTimeout(timeout: Long) = analyticsScope.launch(analyticsDispatcher) {
59+
delay(timeout)
5860
store.dispatch(System.ForceRunningAction(), System::class)
5961
}
6062

0 commit comments

Comments
 (0)