Commit 4da0d7d9 authored by Alex Clarke's avatar Alex Clarke Committed by Commit Bot

Add interfaces for Java TaskRunners with a subset of the C++ functionality

The intent of this patch is to define the interfaces which will be implemented
by subsequent patches.  The interfaces are a subset of the C++ ones including
what we believe is the minimum requried to be useful.

Design doc: https://docs.google.com/document/d/1z1BDq9vzcEpkhN9LSPF5XMnZ0kLJ8mWWkNAi4OI7cos/edit#

Bug: 863341, 872372
Change-Id: Ic608660a13c55c4b17d3ba5fa3bb636783735645
Reviewed-on: https://chromium-review.googlesource.com/1245790
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: default avatarSam Maier <smaier@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595057}
parent 9dfcddf1
...@@ -2973,7 +2973,10 @@ if (is_android) { ...@@ -2973,7 +2973,10 @@ if (is_android) {
"android/java/src/org/chromium/base/memory/MemoryPressureUma.java", "android/java/src/org/chromium/base/memory/MemoryPressureUma.java",
"android/java/src/org/chromium/base/task/AsyncTask.java", "android/java/src/org/chromium/base/task/AsyncTask.java",
"android/java/src/org/chromium/base/task/ChromeThreadPoolExecutor.java", "android/java/src/org/chromium/base/task/ChromeThreadPoolExecutor.java",
"android/java/src/org/chromium/base/task/SequencedTaskRunner.java",
"android/java/src/org/chromium/base/task/SerialExecutor.java", "android/java/src/org/chromium/base/task/SerialExecutor.java",
"android/java/src/org/chromium/base/task/SingleThreadTaskRunner.java",
"android/java/src/org/chromium/base/task/TaskRunner.java",
] ]
# New versions of BuildConfig.java and NativeLibraries.java # New versions of BuildConfig.java and NativeLibraries.java
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.base.task;
/**
* Tasks posted will be run in order with respect to this sequence, but they may be executed
* on arbitrary threads. Unless specified otherwise by the provider of a given
* SequencedTaskRunner, tasks posted to it have no ordering, nor mutual exclusion, execution
* guarantees w.r.t. other SequencedTaskRunners.
*/
public interface SequencedTaskRunner extends TaskRunner {}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.base.task;
/**
* Tasks posted will be run in order on a single thread.
*/
public interface SingleThreadTaskRunner extends SequencedTaskRunner {}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.base.task;
/**
* A task queue that posts Java tasks onto the C++ browser scheduler, if loaded. Otherwise this
* will be backed by an {@link android.os.Handler} or the java thread pool. The TaskQueue interface
* provides no guarantee over the order or the thread on which the task will be executed.
*
* Very similar to {@link java.util.concurrent.Executor} but conforms to chromium terminology.
*/
public interface TaskRunner {
/**
* Posts a task to run immediately.
*
* @param task The task to be run immediately.
*/
public void postTask(Runnable task);
/**
* Instructs the TaskRunner to initialize the native TaskRunner and migrate any tasks over to
* it.
*/
void initNativeTaskRunner();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment