discord-jadx/app/src/main/java/com/discord/stores/utilities/BatchManager.java

61 lines
2.1 KiB
Java

package com.discord.stores.utilities;
import c.q.a.k.a;
import com.discord.utilities.time.Clock;
import com.discord.utilities.time.ClockFactory;
import d0.z.d.m;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.CoroutineScope;
/* compiled from: BatchManager.kt */
public final class BatchManager {
private final Map<String, Batched<?>> batches;
private final Clock clock;
private final CoroutineScope scope;
public BatchManager(CoroutineDispatcher coroutineDispatcher, Clock clock) {
m.checkNotNullParameter(coroutineDispatcher, "dispatcher");
m.checkNotNullParameter(clock, "clock");
this.clock = clock;
this.scope = a.a(coroutineDispatcher);
this.batches = new LinkedHashMap();
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ BatchManager(CoroutineDispatcher coroutineDispatcher, Clock clock, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(coroutineDispatcher, (i & 2) != 0 ? ClockFactory.get() : clock);
}
public static /* synthetic */ Batched createBatched$default(BatchManager batchManager, String str, long j, long j2, int i, Object obj) {
if ((i & 2) != 0) {
j = 100;
}
if ((i & 4) != 0) {
j2 = 300;
}
return batchManager.createBatched(str, j, j2);
}
public final <T> Batched<T> createBatched(String str, long j, long j2) {
m.checkNotNullParameter(str, "type");
Batched<T> batched = new Batched<>(str, j, j2, this.scope, this.clock);
this.batches.put(str, batched);
return batched;
}
public final void dispose() {
a.i(this.scope, null);
}
public final void flushBatches(String str) {
for (Map.Entry<String, Batched<?>> entry : this.batches.entrySet()) {
Batched<?> value = entry.getValue();
if (!m.areEqual(entry.getKey(), str)) {
value.flush();
}
}
}
}