Run ROOM queries/transaction at foreground priority

This commit is contained in:
M66B
2019-06-07 08:10:58 +02:00
parent 3205db6798
commit 9c7399c9e7
2 changed files with 13 additions and 2 deletions

View File

@@ -105,12 +105,23 @@ public class Helper {
@Override
public Thread newThread(@NonNull Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setName("FairEmail_" + threadId.getAndIncrement());
thread.setName("FairEmail_bg_" + threadId.getAndIncrement());
thread.setPriority(THREAD_PRIORITY_BACKGROUND);
return thread;
}
};
static ThreadFactory foregroundThreadFactory = new ThreadFactory() {
private final AtomicInteger threadId = new AtomicInteger();
@Override
public Thread newThread(@NonNull Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setName("FairEmail_fg_" + threadId.getAndIncrement());
return thread;
}
};
// Features
static boolean hasPermission(Context context, String name) {