Skip to content

Commit

Permalink
Android: Webapp register and get splash screen AsyncTasks to thread pool
Browse files Browse the repository at this point in the history
Currently, AsyncTask.execute() defaults to the SERIAL_EXECUTOR. This
exector is good for preventing concurrency errors since it guarantees
serial execution, but bad for performance since the entire app shares
this single queue.

It looks like these callsites can use the THREAD_POOL_EXECUTOR instead,
since these usages don't appear to rely on the concurrency guarantees
that SERIAL_EXECUTOR provides.

Bug: 869907
Change-Id: Iaf227dc516d1b2c850b9b17ce5d43302ab6532b2
Reviewed-on: https://chromium-review.googlesource.com/1161968
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Commit-Queue: Sam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580780}
  • Loading branch information
Sam Maier authored and Commit Bot committed Aug 5, 2018
1 parent 632667b commit b17eddd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.chromium.base.AsyncTask;

import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

Expand Down Expand Up @@ -44,6 +45,12 @@ public AsyncTask<Result> call() throws Exception {
}
}

@Override
@Implementation
public final AsyncTask<Result> executeOnExecutor(Executor e) {
return execute();
}

@Override
@Implementation
public final Result get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected final void onPostExecute(Bitmap result) {
callback.onDataRetrieved(result);
}
}
.execute();
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected final void onPostExecute(WebappDataStorage storage) {
if (callback != null) callback.onWebappDataStorageRetrieved(storage);
}
}
.execute();
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

/**
Expand Down

0 comments on commit b17eddd

Please sign in to comment.