Introduce thread priorities for threads and handlerthreads.

This commit is contained in:
Clark
2023-03-08 17:29:44 -05:00
committed by Greyson Parrelli
parent 2cef06cd6e
commit 79a062c838
22 changed files with 88 additions and 33 deletions

View File

@@ -14,6 +14,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.greenrobot.eventbus.EventBus;
import org.signal.core.util.ThreadUtil;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
@@ -80,7 +81,7 @@ final class DeviceTransferClient implements Handler.Callback {
this.context = context;
this.clientTask = clientTask;
this.shutdownCallback = shutdownCallback;
this.commandAndControlThread = SignalExecutors.getAndStartHandlerThread("client-cnc");
this.commandAndControlThread = SignalExecutors.getAndStartHandlerThread("client-cnc", ThreadUtil.PRIORITY_IMPORTANT_BACKGROUND_THREAD);
this.handler = new Handler(commandAndControlThread.getLooper(), this);
this.autoRestart = () -> {
Log.i(TAG, "Restarting WiFi Direct since we haven't found anything yet and it could be us.");

View File

@@ -14,6 +14,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.greenrobot.eventbus.EventBus;
import org.signal.core.util.ThreadUtil;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.signal.devicetransfer.SelfSignedIdentity.SelfSignedKeys;
@@ -70,7 +71,7 @@ final class DeviceTransferServer implements Handler.Callback {
this.context = context;
this.serverTask = serverTask;
this.shutdownCallback = shutdownCallback;
this.commandAndControlThread = SignalExecutors.getAndStartHandlerThread("server-cnc");
this.commandAndControlThread = SignalExecutors.getAndStartHandlerThread("server-cnc", ThreadUtil.PRIORITY_IMPORTANT_BACKGROUND_THREAD);
this.handler = new Handler(commandAndControlThread.getLooper(), this);
}

View File

@@ -92,7 +92,7 @@ public final class WifiDirect {
WifiDirect(@NonNull Context context) {
this.context = context.getApplicationContext();
this.wifiDirectCallbacksHandler = SignalExecutors.getAndStartHandlerThread("wifi-direct-cb");
this.wifiDirectCallbacksHandler = SignalExecutors.getAndStartHandlerThread("wifi-direct-cb", ThreadUtil.PRIORITY_IMPORTANT_BACKGROUND_THREAD);
}
/**