QueueMemento : fix synchronized

This commit is contained in:
ganfra 2020-12-11 19:18:48 +01:00
parent 629488bbe6
commit b1f492de58

View file

@ -49,9 +49,11 @@ internal class QueueMemento @Inject constructor(context: Context,
}
fun unTrack(task: QueuedTask) {
synchronized(managedTaskInfos) {
managedTaskInfos.remove(task)
persist()
}
}
private fun persist() {
managedTaskInfos.mapIndexedNotNull { index, queuedTask ->
@ -64,7 +66,6 @@ internal class QueueMemento @Inject constructor(context: Context,
}
private fun toTaskInfo(task: QueuedTask, order: Int): TaskInfo? {
synchronized(managedTaskInfos) {
return when (task) {
is SendEventQueuedTask -> SendEventTaskInfo(
localEchoId = task.event.eventId ?: "",
@ -78,7 +79,6 @@ internal class QueueMemento @Inject constructor(context: Context,
else -> null
}
}
}
suspend fun restoreTasks(eventProcessor: EventSenderProcessor) {
// events should be restarted in correct order