diff --git a/core/java/com/android/internal/util/function/pooled/OmniFunction.java b/core/java/com/android/internal/util/function/pooled/OmniFunction.java
index b6d2dedc1bfdd..931477f0b3325 100755
--- a/core/java/com/android/internal/util/function/pooled/OmniFunction.java
+++ b/core/java/com/android/internal/util/function/pooled/OmniFunction.java
@@ -51,13 +51,13 @@ import java.util.function.Function;
* @hide
*/
abstract class OmniFunction implements
- PooledFunction, BiFunction, TriFunction,
+ BiFunction, TriFunction,
QuadFunction, QuintFunction,
HexFunction, HeptFunction,
OctFunction, NonaFunction,
DecFunction,
UndecFunction,
- PooledConsumer, BiConsumer, TriConsumer, QuadConsumer,
+ BiConsumer, TriConsumer, QuadConsumer,
QuintConsumer, HexConsumer,
HeptConsumer, OctConsumer,
NonaConsumer, DecConsumer,
@@ -73,11 +73,6 @@ abstract class OmniFunction implements
return invoke(o, o2, null, null, null, null, null, null, null, null, null);
}
- @Override
- public R apply(A o) {
- return invoke(o, null, null, null, null, null, null, null, null, null, null);
- }
-
public abstract OmniFunction andThen(
Function super R, ? extends V> after);
public abstract OmniFunction negate();
@@ -87,11 +82,6 @@ abstract class OmniFunction implements
invoke(o, o2, null, null, null, null, null, null, null, null, null);
}
- @Override
- public void accept(A o) {
- invoke(o, null, null, null, null, null, null, null, null, null, null);
- }
-
@Override
public void run() {
invoke(null, null, null, null, null, null, null, null, null, null, null);
@@ -132,11 +122,6 @@ abstract class OmniFunction implements
return this;
}
- @Override
- public PooledConsumer asConsumer() {
- return this;
- }
-
@Override
public R apply(A a, B b, C c) {
return invoke(a, b, c, null, null, null, null, null, null, null, null);
diff --git a/core/java/com/android/internal/util/function/pooled/PooledConsumer.java b/core/java/com/android/internal/util/function/pooled/PooledConsumer.java
deleted file mode 100644
index f66586ee67911..0000000000000
--- a/core/java/com/android/internal/util/function/pooled/PooledConsumer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.util.function.pooled;
-
-import java.util.function.Consumer;
-
-/**
- * {@link Consumer} + {@link PooledLambda}
- *
- * @see PooledLambda
- * @hide
- */
-public interface PooledConsumer extends PooledLambda, Consumer {
-
- /** @inheritDoc */
- PooledConsumer recycleOnUse();
-}
diff --git a/core/java/com/android/internal/util/function/pooled/PooledFunction.java b/core/java/com/android/internal/util/function/pooled/PooledFunction.java
deleted file mode 100644
index 1f166fafc7e65..0000000000000
--- a/core/java/com/android/internal/util/function/pooled/PooledFunction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.util.function.pooled;
-
-import java.util.function.Function;
-
-/**
- * {@link Function} + {@link PooledLambda}
- *
- * @see PooledLambda
- * @hide
- */
-public interface PooledFunction extends PooledLambda, Function {
-
- /**
- * Ignores the result
- */
- PooledConsumer asConsumer();
-
- /** @inheritDoc */
- PooledFunction recycleOnUse();
-}
diff --git a/core/java/com/android/internal/util/function/pooled/PooledLambda.java b/core/java/com/android/internal/util/function/pooled/PooledLambda.java
index 2bfde242a9871..bdc8a668a7f78 100755
--- a/core/java/com/android/internal/util/function/pooled/PooledLambda.java
+++ b/core/java/com/android/internal/util/function/pooled/PooledLambda.java
@@ -232,24 +232,6 @@ public interface PooledLambda {
null, null, null, null);
}
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 placeholder for a missing argument. Use {@link #__} to get one
- * @param arg2 parameter supplied to {@code function} on call
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg1) -> function(arg1, arg2) }
- */
- static PooledConsumer obtainConsumer(
- BiConsumer super A, ? super B> function,
- ArgumentPlaceholder arg1, B arg2) {
- return acquire(PooledLambdaImpl.sPool,
- function, 2, 1, ReturnType.VOID, arg1, arg2, null, null, null, null, null, null,
- null, null, null, null);
- }
-
/**
* {@link PooledPredicate} factory
*
@@ -328,24 +310,6 @@ public interface PooledLambda {
null, null, null, null);
}
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 parameter supplied to {@code function} on call
- * @param arg2 placeholder for a missing argument. Use {@link #__} to get one
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg2) -> function(arg1, arg2) }
- */
- static PooledConsumer obtainConsumer(
- BiConsumer super A, ? super B> function,
- A arg1, ArgumentPlaceholder arg2) {
- return acquire(PooledLambdaImpl.sPool,
- function, 2, 1, ReturnType.VOID, arg1, arg2, null, null, null, null, null, null,
- null, null, null, null);
- }
-
/**
* {@link PooledPredicate} factory
*
@@ -417,63 +381,6 @@ public interface PooledLambda {
null, null, null, null);
}
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 placeholder for a missing argument. Use {@link #__} to get one
- * @param arg2 parameter supplied to {@code function} on call
- * @param arg3 parameter supplied to {@code function} on call
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg1) -> function(arg1, arg2, arg3) }
- */
- static PooledConsumer obtainConsumer(
- TriConsumer super A, ? super B, ? super C> function,
- ArgumentPlaceholder arg1, B arg2, C arg3) {
- return acquire(PooledLambdaImpl.sPool,
- function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null,
- null, null, null, null);
- }
-
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 parameter supplied to {@code function} on call
- * @param arg2 placeholder for a missing argument. Use {@link #__} to get one
- * @param arg3 parameter supplied to {@code function} on call
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg2) -> function(arg1, arg2, arg3) }
- */
- static PooledConsumer obtainConsumer(
- TriConsumer super A, ? super B, ? super C> function,
- A arg1, ArgumentPlaceholder arg2, C arg3) {
- return acquire(PooledLambdaImpl.sPool,
- function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null,
- null, null, null, null);
- }
-
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 parameter supplied to {@code function} on call
- * @param arg2 parameter supplied to {@code function} on call
- * @param arg3 placeholder for a missing argument. Use {@link #__} to get one
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg3) -> function(arg1, arg2, arg3) }
- */
- static PooledConsumer obtainConsumer(
- TriConsumer super A, ? super B, ? super C> function,
- A arg1, B arg2, ArgumentPlaceholder arg3) {
- return acquire(PooledLambdaImpl.sPool,
- function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null,
- null, null, null, null);
- }
-
/**
* Factory of {@link Message}s that contain an
* ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its
@@ -529,86 +436,6 @@ public interface PooledLambda {
null, null, null, null);
}
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 placeholder for a missing argument. Use {@link #__} to get one
- * @param arg2 parameter supplied to {@code function} on call
- * @param arg3 parameter supplied to {@code function} on call
- * @param arg4 parameter supplied to {@code function} on call
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg1) -> function(arg1, arg2, arg3, arg4) }
- */
- static PooledConsumer obtainConsumer(
- QuadConsumer super A, ? super B, ? super C, ? super D> function,
- ArgumentPlaceholder arg1, B arg2, C arg3, D arg4) {
- return acquire(PooledLambdaImpl.sPool,
- function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null,
- null, null, null, null);
- }
-
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 parameter supplied to {@code function} on call
- * @param arg2 placeholder for a missing argument. Use {@link #__} to get one
- * @param arg3 parameter supplied to {@code function} on call
- * @param arg4 parameter supplied to {@code function} on call
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg2) -> function(arg1, arg2, arg3, arg4) }
- */
- static PooledConsumer obtainConsumer(
- QuadConsumer super A, ? super B, ? super C, ? super D> function,
- A arg1, ArgumentPlaceholder arg2, C arg3, D arg4) {
- return acquire(PooledLambdaImpl.sPool,
- function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null,
- null, null, null, null);
- }
-
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 parameter supplied to {@code function} on call
- * @param arg2 parameter supplied to {@code function} on call
- * @param arg3 placeholder for a missing argument. Use {@link #__} to get one
- * @param arg4 parameter supplied to {@code function} on call
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg3) -> function(arg1, arg2, arg3, arg4) }
- */
- static PooledConsumer obtainConsumer(
- QuadConsumer super A, ? super B, ? super C, ? super D> function,
- A arg1, B arg2, ArgumentPlaceholder arg3, D arg4) {
- return acquire(PooledLambdaImpl.sPool,
- function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null,
- null, null, null, null);
- }
-
- /**
- * {@link PooledConsumer} factory
- *
- * @param function non-capturing lambda(typically an unbounded method reference)
- * to be invoked on call
- * @param arg1 parameter supplied to {@code function} on call
- * @param arg2 parameter supplied to {@code function} on call
- * @param arg3 parameter supplied to {@code function} on call
- * @param arg4 placeholder for a missing argument. Use {@link #__} to get one
- * @return a {@link PooledConsumer}, equivalent to lambda:
- * {@code (arg4) -> function(arg1, arg2, arg3, arg4) }
- */
- static PooledConsumer obtainConsumer(
- QuadConsumer super A, ? super B, ? super C, ? super D> function,
- A arg1, B arg2, C arg3, ArgumentPlaceholder arg4) {
- return acquire(PooledLambdaImpl.sPool,
- function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null,
- null, null, null, null);
- }
-
/**
* Factory of {@link Message}s that contain an
* ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its
diff --git a/core/java/com/android/internal/util/function/pooled/PooledPredicate.java b/core/java/com/android/internal/util/function/pooled/PooledPredicate.java
index 9b14366452e58..91a8607677a59 100644
--- a/core/java/com/android/internal/util/function/pooled/PooledPredicate.java
+++ b/core/java/com/android/internal/util/function/pooled/PooledPredicate.java
@@ -26,11 +26,6 @@ import java.util.function.Predicate;
*/
public interface PooledPredicate extends PooledLambda, Predicate {
- /**
- * Ignores the result
- */
- PooledConsumer asConsumer();
-
/** @inheritDoc */
PooledPredicate recycleOnUse();
}
diff --git a/tests/benchmarks/internal/src/com/android/internal/LambdaPerfTest.java b/tests/benchmarks/internal/src/com/android/internal/LambdaPerfTest.java
index 2001c04bd6451..0a03e8d6534a8 100644
--- a/tests/benchmarks/internal/src/com/android/internal/LambdaPerfTest.java
+++ b/tests/benchmarks/internal/src/com/android/internal/LambdaPerfTest.java
@@ -29,7 +29,6 @@ import android.util.Log;
import androidx.test.filters.LargeTest;
-import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledPredicate;
@@ -46,7 +45,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CountDownLatch;
-import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -94,27 +92,27 @@ public class LambdaPerfTest {
};
@Test
- public void test1ParamConsumer() {
- evaluate(LAMBDA_FORM_REGULAR, () -> forAllTask(t -> t.doSomething(mTask)));
+ public void test1ParamPredicate() {
+ evaluate(LAMBDA_FORM_REGULAR, () -> handleTask(t -> t.doSomething(mTaskId, mTime)));
evaluate(LAMBDA_FORM_POOLED, () -> {
- final PooledConsumer c = PooledLambda.obtainConsumer(Task::doSomething,
- PooledLambda.__(Task.class), mTask);
- forAllTask(c);
+ final PooledPredicate c = PooledLambda.obtainPredicate(Task::doSomething,
+ PooledLambda.__(Task.class), mTaskId, mTime);
+ handleTask(c);
c.recycle();
});
}
@Test
- public void test2PrimitiveParamsConsumer() {
+ public void test2PrimitiveParamsPredicate() {
// Not in Integer#IntegerCache (-128~127) for autoboxing, that may create new object.
mTaskId = 12345;
mTime = 54321;
- evaluate(LAMBDA_FORM_REGULAR, () -> forAllTask(t -> t.doSomething(mTaskId, mTime)));
+ evaluate(LAMBDA_FORM_REGULAR, () -> handleTask(t -> t.doSomething(mTaskId, mTime)));
evaluate(LAMBDA_FORM_POOLED, () -> {
- final PooledConsumer c = PooledLambda.obtainConsumer(Task::doSomething,
+ final PooledPredicate c = PooledLambda.obtainPredicate(Task::doSomething,
PooledLambda.__(Task.class), mTaskId, mTime);
- forAllTask(c);
+ handleTask(c);
c.recycle();
});
}
@@ -164,15 +162,15 @@ public class LambdaPerfTest {
public void testMultiThread() {
final int numThread = 3;
- final Runnable regularAction = () -> forAllTask(t -> t.doSomething(mTask));
+ final Runnable regularAction = () -> handleTask(t -> t.doSomething(mTaskId, mTime));
final Runnable[] regularActions = new Runnable[numThread];
Arrays.fill(regularActions, regularAction);
evaluateMultiThread(LAMBDA_FORM_REGULAR, regularActions);
final Runnable pooledAction = () -> {
- final PooledConsumer c = PooledLambda.obtainConsumer(Task::doSomething,
- PooledLambda.__(Task.class), mTask);
- forAllTask(c);
+ final PooledPredicate c = PooledLambda.obtainPredicate(Task::doSomething,
+ PooledLambda.__(Task.class), mTaskId, mTime);
+ handleTask(c);
c.recycle();
};
final Runnable[] pooledActions = new Runnable[numThread];
@@ -180,12 +178,6 @@ public class LambdaPerfTest {
evaluateMultiThread(LAMBDA_FORM_POOLED, pooledActions);
}
- private void forAllTask(Consumer callback) {
- for (int i = mTasks.size() - 1; i >= 0; i--) {
- callback.accept(mTasks.get(i));
- }
- }
-
private void handleTask(Predicate callback) {
for (int i = mTasks.size() - 1; i >= 0; i--) {
final Task task = mTasks.get(i);
@@ -318,10 +310,8 @@ public class LambdaPerfTest {
void doSomething() {
}
- void doSomething(Task t) {
- }
-
- void doSomething(int taskId, long time) {
+ boolean doSomething(int taskId, long time) {
+ return false;
}
boolean doSomething(Rect bounds, boolean top, int taskId) {