We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1905ffc commit 8a518ceCopy full SHA for 8a518ce
parsely/src/main/java/com/parsely/parselyandroid/InMemoryBuffer.kt
@@ -1,6 +1,9 @@
1
package com.parsely.parselyandroid
2
3
+import kotlin.time.Duration.Companion.seconds
4
import kotlinx.coroutines.CoroutineScope
5
+import kotlinx.coroutines.delay
6
+import kotlinx.coroutines.isActive
7
import kotlinx.coroutines.launch
8
import kotlinx.coroutines.sync.Mutex
9
import kotlinx.coroutines.sync.withLock
@@ -15,13 +18,14 @@ internal class InMemoryBuffer(
15
18
16
19
init {
17
20
coroutineScope.launch {
- while (true) {
21
+ while (isActive) {
22
mutex.withLock {
23
if (buffer.isNotEmpty()) {
24
localStorageRepository.insertEvents(buffer)
25
buffer.clear()
26
}
27
28
+ delay(1.seconds)
29
30
31
0 commit comments