@@ -27,34 +27,36 @@ interface WaitingPlugin: Plugin {
27
27
}
28
28
}
29
29
30
- fun Analytics.pauseEventProcessing (plugin : WaitingPlugin ) = analyticsScope.launch {
30
+ fun Analytics.pauseEventProcessing (plugin : WaitingPlugin ) = analyticsScope.launch(analyticsDispatcher) {
31
31
store.dispatch(System .AddWaitingPlugin (plugin.hashCode()), System ::class )
32
+ pauseEventProcessing()
32
33
}
33
34
34
35
35
- fun Analytics.resumeEventProcessing (plugin : WaitingPlugin ) = analyticsScope.launch {
36
+ fun Analytics.resumeEventProcessing (plugin : WaitingPlugin ) = analyticsScope.launch(analyticsDispatcher) {
36
37
store.dispatch(System .RemoveWaitingPlugin (plugin.hashCode()), System ::class )
38
+ resumeEventProcessing()
37
39
}
38
40
39
41
internal suspend fun Analytics.running (): Boolean {
40
42
val system = store.currentState(System ::class )
41
43
return system?.running ? : false
42
44
}
43
45
44
- internal suspend fun Analytics.pauseEventProcessing () {
46
+ internal suspend fun Analytics.pauseEventProcessing (timeout : Long = 30_000 ) {
45
47
if (! running()) return
46
48
47
49
store.dispatch(System .ToggleRunningAction (false ), System ::class )
48
- startProcessingAfterTimeout()
50
+ startProcessingAfterTimeout(timeout )
49
51
}
50
52
51
53
internal suspend fun Analytics.resumeEventProcessing () {
52
54
if (running()) return
53
55
store.dispatch(System .ToggleRunningAction (true ), System ::class )
54
56
}
55
57
56
- internal fun Analytics.startProcessingAfterTimeout () = analyticsScope.launch {
57
- delay(30_000 )
58
+ internal fun Analytics.startProcessingAfterTimeout (timeout : Long ) = analyticsScope.launch(analyticsDispatcher) {
59
+ delay(timeout )
58
60
store.dispatch(System .ForceRunningAction (), System ::class )
59
61
}
60
62
0 commit comments