kopia lustrzana https://github.com/ryukoposting/Signal-Android
Adjust SignalExecutors.BOUNDED config to actually use extra threads.
rodzic
3bd354289d
commit
03ad5073d2
|
@ -121,7 +121,7 @@ public class ApplicationDependencyProvider implements ApplicationDependencies.Pr
|
||||||
signalWebSocket,
|
signalWebSocket,
|
||||||
Optional.of(new SecurityEventListener(context)),
|
Optional.of(new SecurityEventListener(context)),
|
||||||
provideClientZkOperations().getProfileOperations(),
|
provideClientZkOperations().getProfileOperations(),
|
||||||
SignalExecutors.newCachedBoundedExecutor("signal-messages", 1, 16),
|
SignalExecutors.newCachedBoundedExecutor("signal-messages", 1, 16, 30),
|
||||||
ByteUnit.KILOBYTES.toBytes(512),
|
ByteUnit.KILOBYTES.toBytes(512),
|
||||||
FeatureFlags.okHttpAutomaticRetry());
|
FeatureFlags.okHttpAutomaticRetry());
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
public final class SignalExecutors {
|
public final class SignalExecutors {
|
||||||
|
|
||||||
public static final ExecutorService UNBOUNDED = Executors.newCachedThreadPool(new NumberedThreadFactory("signal-unbounded"));
|
public static final ExecutorService UNBOUNDED = Executors.newCachedThreadPool(new NumberedThreadFactory("signal-unbounded"));
|
||||||
public static final ExecutorService BOUNDED = new ThreadPoolExecutor(4, 12, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NumberedThreadFactory("signal-bounded"));
|
public static final ExecutorService BOUNDED = newCachedBoundedExecutor("signal-bounded", 4, 12, 5);
|
||||||
public static final ExecutorService SERIAL = Executors.newSingleThreadExecutor(new NumberedThreadFactory("signal-serial"));
|
public static final ExecutorService SERIAL = Executors.newSingleThreadExecutor(new NumberedThreadFactory("signal-serial"));
|
||||||
public static final ExecutorService BOUNDED_IO = newCachedBoundedExecutor("signal-io-bounded", 1, 32);
|
public static final ExecutorService BOUNDED_IO = newCachedBoundedExecutor("signal-io-bounded", 1, 32, 30);
|
||||||
|
|
||||||
private SignalExecutors() {}
|
private SignalExecutors() {}
|
||||||
|
|
||||||
|
@ -40,10 +40,10 @@ public final class SignalExecutors {
|
||||||
* So we make a queue that will always return false if it's non-empty to ensure new threads get
|
* So we make a queue that will always return false if it's non-empty to ensure new threads get
|
||||||
* created. Then, if a task gets rejected, we simply add it to the queue.
|
* created. Then, if a task gets rejected, we simply add it to the queue.
|
||||||
*/
|
*/
|
||||||
public static ExecutorService newCachedBoundedExecutor(final String name, int minThreads, int maxThreads) {
|
public static ExecutorService newCachedBoundedExecutor(final String name, int minThreads, int maxThreads, int timeoutSeconds) {
|
||||||
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(minThreads,
|
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(minThreads,
|
||||||
maxThreads,
|
maxThreads,
|
||||||
30,
|
timeoutSeconds,
|
||||||
TimeUnit.SECONDS,
|
TimeUnit.SECONDS,
|
||||||
new LinkedBlockingQueue<Runnable>() {
|
new LinkedBlockingQueue<Runnable>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Ładowanie…
Reference in New Issue