1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.util.function.pooled; 18 19 import static com.android.internal.util.function.pooled.PooledLambdaImpl.acquire; 20 import static com.android.internal.util.function.pooled.PooledLambdaImpl.acquireConstSupplier; 21 22 import android.os.Message; 23 24 import com.android.internal.util.function.DecConsumer; 25 import com.android.internal.util.function.DecFunction; 26 import com.android.internal.util.function.DodecConsumer; 27 import com.android.internal.util.function.DodecFunction; 28 import com.android.internal.util.function.HeptConsumer; 29 import com.android.internal.util.function.HeptFunction; 30 import com.android.internal.util.function.HexConsumer; 31 import com.android.internal.util.function.HexFunction; 32 import com.android.internal.util.function.NonaConsumer; 33 import com.android.internal.util.function.NonaFunction; 34 import com.android.internal.util.function.OctConsumer; 35 import com.android.internal.util.function.OctFunction; 36 import com.android.internal.util.function.QuadConsumer; 37 import com.android.internal.util.function.QuadFunction; 38 import com.android.internal.util.function.QuadPredicate; 39 import com.android.internal.util.function.QuintConsumer; 40 import com.android.internal.util.function.QuintFunction; 41 import com.android.internal.util.function.QuintPredicate; 42 import com.android.internal.util.function.TriConsumer; 43 import com.android.internal.util.function.TriFunction; 44 import com.android.internal.util.function.TriPredicate; 45 import com.android.internal.util.function.UndecConsumer; 46 import com.android.internal.util.function.UndecFunction; 47 import com.android.internal.util.function.pooled.PooledLambdaImpl.LambdaType.ReturnType; 48 49 import java.util.function.BiConsumer; 50 import java.util.function.BiFunction; 51 import java.util.function.BiPredicate; 52 import java.util.function.Consumer; 53 import java.util.function.Function; 54 import java.util.function.Predicate; 55 import java.util.function.Supplier; 56 57 /** 58 * A recyclable anonymous function. 59 * Allows obtaining {@link Function}s/{@link Runnable}s/{@link Supplier}s/etc. without allocating a 60 * new instance each time 61 * 62 * This exploits the mechanic that stateless lambdas (such as plain/non-bound method references) 63 * get translated into a singleton instance, making it possible to create a recyclable container 64 * ({@link PooledLambdaImpl}) holding a reference to such a singleton function, as well as 65 * (possibly partial) arguments required for its invocation. 66 * 67 * To obtain an instance, use one of the factory methods in this class. 68 * 69 * You can call {@link #recycleOnUse} to make the instance automatically recycled upon invocation, 70 * making if effectively <b>one-time use</b>. 71 * This is often the behavior you want, as it allows to not worry about manual recycling. 72 * Some notable examples: {@link android.os.Handler#post(Runnable)}, 73 * {@link android.app.Activity#runOnUiThread(Runnable)}, {@link android.view.View#post(Runnable)} 74 * 75 * For factories of functions that take further arguments, the corresponding 'missing' argument's 76 * position is marked by an argument of type {@link ArgumentPlaceholder} with the type parameter 77 * corresponding to missing argument's type. 78 * You can fill the 'missing argument' spot with {@link #__()} 79 * (which is the factory function for {@link ArgumentPlaceholder}) 80 * 81 * NOTE: It is highly recommended to <b>only</b> use {@code ClassName::methodName} 82 * (aka unbounded method references) as the 1st argument for any of the 83 * factories ({@code obtain*(...)}) to avoid unwanted allocations. 84 * This means <b>not</b> using: 85 * <ul> 86 * <li>{@code someVar::methodName} or {@code this::methodName} as it captures the reference 87 * on the left of {@code ::}, resulting in an allocation on each evaluation of such 88 * bounded method references</li> 89 * 90 * <li>A lambda expression, e.g. {@code () -> toString()} due to how easy it is to accidentally 91 * capture state from outside. In the above lambda expression for example, no variable from 92 * outer scope is explicitly mentioned, yet one is still captured due to {@code toString()} 93 * being an equivalent of {@code this.toString()}</li> 94 * </ul> 95 * 96 * @hide 97 */ 98 @SuppressWarnings({"unchecked", "unused", "WeakerAccess"}) 99 public interface PooledLambda { 100 101 /** 102 * Recycles this instance. No-op if already recycled. 103 */ recycle()104 void recycle(); 105 106 /** 107 * Makes this instance automatically {@link #recycle} itself after the first call. 108 * 109 * @return this instance for convenience 110 */ recycleOnUse()111 PooledLambda recycleOnUse(); 112 113 114 // Factories 115 116 /** 117 * @return {@link ArgumentPlaceholder} with the inferred type parameter value 118 */ __()119 static <R> ArgumentPlaceholder<R> __() { 120 return (ArgumentPlaceholder<R>) ArgumentPlaceholder.INSTANCE; 121 } 122 123 /** 124 * @param typeHint the explicitly specified type of the missing argument 125 * @return {@link ArgumentPlaceholder} with the specified type parameter value 126 */ __(Class<R> typeHint)127 static <R> ArgumentPlaceholder<R> __(Class<R> typeHint) { 128 return __(); 129 } 130 131 /** 132 * Wraps the given value into a {@link PooledSupplier} 133 * 134 * @param value a value to wrap 135 * @return a pooled supplier of {@code value} 136 */ obtainSupplier(R value)137 static <R> PooledSupplier<R> obtainSupplier(R value) { 138 PooledLambdaImpl r = acquireConstSupplier(ReturnType.OBJECT); 139 r.mFunc = value; 140 return r; 141 } 142 143 /** 144 * Wraps the given value into a {@link PooledSupplier} 145 * 146 * @param value a value to wrap 147 * @return a pooled supplier of {@code value} 148 */ obtainSupplier(int value)149 static PooledSupplier.OfInt obtainSupplier(int value) { 150 PooledLambdaImpl r = acquireConstSupplier(ReturnType.INT); 151 r.mConstValue = value; 152 return r; 153 } 154 155 /** 156 * Wraps the given value into a {@link PooledSupplier} 157 * 158 * @param value a value to wrap 159 * @return a pooled supplier of {@code value} 160 */ obtainSupplier(long value)161 static PooledSupplier.OfLong obtainSupplier(long value) { 162 PooledLambdaImpl r = acquireConstSupplier(ReturnType.LONG); 163 r.mConstValue = value; 164 return r; 165 } 166 167 /** 168 * Wraps the given value into a {@link PooledSupplier} 169 * 170 * @param value a value to wrap 171 * @return a pooled supplier of {@code value} 172 */ obtainSupplier(double value)173 static PooledSupplier.OfDouble obtainSupplier(double value) { 174 PooledLambdaImpl r = acquireConstSupplier(ReturnType.DOUBLE); 175 r.mConstValue = Double.doubleToRawLongBits(value); 176 return r; 177 } 178 179 /** 180 * {@link PooledRunnable} factory 181 * 182 * @param function non-capturing lambda(typically an unbounded method reference) 183 * to be invoked on call 184 * @param arg1 parameter supplied to {@code function} on call 185 * @return a {@link PooledRunnable}, equivalent to lambda: 186 * {@code () -> function(arg1) } 187 */ obtainRunnable( Consumer<? super A> function, A arg1)188 static <A> PooledRunnable obtainRunnable( 189 Consumer<? super A> function, 190 A arg1) { 191 return acquire(PooledLambdaImpl.sPool, 192 function, 1, 0, ReturnType.VOID, arg1, null, null, null, null, null, null, null, 193 null, null, null, null); 194 } 195 196 /** 197 * {@link PooledSupplier} factory 198 * 199 * @param function non-capturing lambda(typically an unbounded method reference) 200 * to be invoked on call 201 * @param arg1 parameter supplied to {@code function} on call 202 * @return a {@link PooledSupplier}, equivalent to lambda: 203 * {@code () -> function(arg1) } 204 */ obtainSupplier( Predicate<? super A> function, A arg1)205 static <A> PooledSupplier<Boolean> obtainSupplier( 206 Predicate<? super A> function, 207 A arg1) { 208 return acquire(PooledLambdaImpl.sPool, 209 function, 1, 0, ReturnType.BOOLEAN, arg1, null, null, null, null, null, null, null, 210 null, null, null, null); 211 } 212 213 /** 214 * {@link PooledSupplier} factory 215 * 216 * @param function non-capturing lambda(typically an unbounded method reference) 217 * to be invoked on call 218 * @param arg1 parameter supplied to {@code function} on call 219 * @return a {@link PooledSupplier}, equivalent to lambda: 220 * {@code () -> function(arg1) } 221 */ obtainSupplier( Function<? super A, ? extends R> function, A arg1)222 static <A, R> PooledSupplier<R> obtainSupplier( 223 Function<? super A, ? extends R> function, 224 A arg1) { 225 return acquire(PooledLambdaImpl.sPool, 226 function, 1, 0, ReturnType.OBJECT, arg1, null, null, null, null, null, null, null, 227 null, null, null, null); 228 } 229 230 /** 231 * Factory of {@link Message}s that contain an 232 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 233 * {@link Message#getCallback internal callback}. 234 * 235 * The callback is equivalent to one obtainable via 236 * {@link #obtainRunnable(Consumer, Object)} 237 * 238 * Note that using this method with {@link android.os.Handler#handleMessage} 239 * is more efficient than the alternative of {@link android.os.Handler#post} 240 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 241 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 242 * 243 * You may optionally set a {@link Message#what} for the message if you want to be 244 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 245 * there's no need to do so 246 * 247 * @param function non-capturing lambda(typically an unbounded method reference) 248 * to be invoked on call 249 * @param arg1 parameter supplied to {@code function} on call 250 * @return a {@link Message} invoking {@code function(arg1) } when handled 251 */ obtainMessage( Consumer<? super A> function, A arg1)252 static <A> Message obtainMessage( 253 Consumer<? super A> function, 254 A arg1) { 255 synchronized (Message.sPoolSync) { 256 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 257 function, 1, 0, ReturnType.VOID, arg1, null, null, null, null, null, null, null, 258 null, null, null, null); 259 return Message.obtain().setCallback(callback.recycleOnUse()); 260 } 261 } 262 263 /** 264 * {@link PooledRunnable} factory 265 * 266 * @param function non-capturing lambda(typically an unbounded method reference) 267 * to be invoked on call 268 * @param arg1 parameter supplied to {@code function} on call 269 * @param arg2 parameter supplied to {@code function} on call 270 * @return a {@link PooledRunnable}, equivalent to lambda: 271 * {@code () -> function(arg1, arg2) } 272 */ obtainRunnable( BiConsumer<? super A, ? super B> function, A arg1, B arg2)273 static <A, B> PooledRunnable obtainRunnable( 274 BiConsumer<? super A, ? super B> function, 275 A arg1, B arg2) { 276 return acquire(PooledLambdaImpl.sPool, 277 function, 2, 0, ReturnType.VOID, arg1, arg2, null, null, null, null, null, null, 278 null, null, null, null); 279 } 280 281 /** 282 * {@link PooledSupplier} factory 283 * 284 * @param function non-capturing lambda(typically an unbounded method reference) 285 * to be invoked on call 286 * @param arg1 parameter supplied to {@code function} on call 287 * @param arg2 parameter supplied to {@code function} on call 288 * @return a {@link PooledSupplier}, equivalent to lambda: 289 * {@code () -> function(arg1, arg2) } 290 */ obtainSupplier( BiPredicate<? super A, ? super B> function, A arg1, B arg2)291 static <A, B> PooledSupplier<Boolean> obtainSupplier( 292 BiPredicate<? super A, ? super B> function, 293 A arg1, B arg2) { 294 return acquire(PooledLambdaImpl.sPool, 295 function, 2, 0, ReturnType.BOOLEAN, arg1, arg2, null, null, null, null, null, null, 296 null, null, null, null); 297 } 298 299 /** 300 * {@link PooledSupplier} factory 301 * 302 * @param function non-capturing lambda(typically an unbounded method reference) 303 * to be invoked on call 304 * @param arg1 parameter supplied to {@code function} on call 305 * @param arg2 parameter supplied to {@code function} on call 306 * @return a {@link PooledSupplier}, equivalent to lambda: 307 * {@code () -> function(arg1, arg2) } 308 */ obtainSupplier( BiFunction<? super A, ? super B, ? extends R> function, A arg1, B arg2)309 static <A, B, R> PooledSupplier<R> obtainSupplier( 310 BiFunction<? super A, ? super B, ? extends R> function, 311 A arg1, B arg2) { 312 return acquire(PooledLambdaImpl.sPool, 313 function, 2, 0, ReturnType.OBJECT, arg1, arg2, null, null, null, null, null, null, 314 null, null, null, null); 315 } 316 317 /** 318 * {@link PooledConsumer} factory 319 * 320 * @param function non-capturing lambda(typically an unbounded method reference) 321 * to be invoked on call 322 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 323 * @param arg2 parameter supplied to {@code function} on call 324 * @return a {@link PooledConsumer}, equivalent to lambda: 325 * {@code (arg1) -> function(arg1, arg2) } 326 */ obtainConsumer( BiConsumer<? super A, ? super B> function, ArgumentPlaceholder<A> arg1, B arg2)327 static <A, B> PooledConsumer<A> obtainConsumer( 328 BiConsumer<? super A, ? super B> function, 329 ArgumentPlaceholder<A> arg1, B arg2) { 330 return acquire(PooledLambdaImpl.sPool, 331 function, 2, 1, ReturnType.VOID, arg1, arg2, null, null, null, null, null, null, 332 null, null, null, null); 333 } 334 335 /** 336 * {@link PooledPredicate} factory 337 * 338 * @param function non-capturing lambda(typically an unbounded method reference) 339 * to be invoked on call 340 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 341 * @param arg2 parameter supplied to {@code function} on call 342 * @return a {@link PooledPredicate}, equivalent to lambda: 343 * {@code (arg1) -> function(arg1, arg2) } 344 */ obtainPredicate( BiPredicate<? super A, ? super B> function, ArgumentPlaceholder<A> arg1, B arg2)345 static <A, B> PooledPredicate<A> obtainPredicate( 346 BiPredicate<? super A, ? super B> function, 347 ArgumentPlaceholder<A> arg1, B arg2) { 348 return acquire(PooledLambdaImpl.sPool, 349 function, 2, 1, ReturnType.BOOLEAN, arg1, arg2, null, null, null, null, null, null, 350 null, null, null, null); 351 } 352 353 /** 354 * {@link PooledPredicate} factory 355 * 356 * @param function non-capturing lambda(typically an unbounded method reference) 357 * to be invoked on call 358 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 359 * @param arg2 parameter supplied to {@code function} on call 360 * @param arg3 parameter supplied to {@code function} on call 361 * @return a {@link PooledPredicate}, equivalent to lambda: 362 * {@code (arg1) -> function(arg1, arg2, arg3) } 363 */ obtainPredicate( TriPredicate<? super A, ? super B, ? super C> function, ArgumentPlaceholder<A> arg1, B arg2, C arg3)364 static <A, B, C> PooledPredicate<A> obtainPredicate( 365 TriPredicate<? super A, ? super B, ? super C> function, 366 ArgumentPlaceholder<A> arg1, B arg2, C arg3) { 367 return acquire(PooledLambdaImpl.sPool, 368 function, 3, 1, ReturnType.BOOLEAN, arg1, arg2, arg3, null, null, null, null, null, 369 null, null, null, null); 370 } 371 372 /** 373 * {@link PooledPredicate} factory 374 * 375 * @param function non-capturing lambda(typically an unbounded method reference) 376 * to be invoked on call 377 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 378 * @param arg2 parameter supplied to {@code function} on call 379 * @param arg3 parameter supplied to {@code function} on call 380 * @param arg4 parameter supplied to {@code function} on call 381 * @return a {@link PooledPredicate}, equivalent to lambda: 382 * {@code (arg1) -> function(arg1, arg2, arg3, arg4) } 383 */ obtainPredicate( QuadPredicate<? super A, ? super B, ? super C, ? super D> function, ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4)384 static <A, B, C, D> PooledPredicate<A> obtainPredicate( 385 QuadPredicate<? super A, ? super B, ? super C, ? super D> function, 386 ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4) { 387 return acquire(PooledLambdaImpl.sPool, 388 function, 4, 1, ReturnType.BOOLEAN, arg1, arg2, arg3, arg4, null, null, null, null, 389 null, null, null, null); 390 } 391 392 /** 393 * {@link PooledPredicate} factory 394 * 395 * @param function non-capturing lambda(typically an unbounded method reference) 396 * to be invoked on call 397 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 398 * @param arg2 parameter supplied to {@code function} on call 399 * @param arg3 parameter supplied to {@code function} on call 400 * @param arg4 parameter supplied to {@code function} on call 401 * @param arg5 parameter supplied to {@code function} on call 402 * @return a {@link PooledPredicate}, equivalent to lambda: 403 * {@code (arg1) -> function(arg1, arg2, arg3, arg4, arg5) } 404 */ obtainPredicate( QuintPredicate<? super A, ? super B, ? super C, ? super D, ? super E> function, ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4, E arg5)405 static <A, B, C, D, E> PooledPredicate<A> obtainPredicate( 406 QuintPredicate<? super A, ? super B, ? super C, ? super D, ? super E> function, 407 ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4, E arg5) { 408 return acquire(PooledLambdaImpl.sPool, 409 function, 5, 1, ReturnType.BOOLEAN, arg1, arg2, arg3, arg4, arg5, null, null, null, 410 null, null, null, null); 411 } 412 413 /** 414 * {@link PooledFunction} factory 415 * 416 * @param function non-capturing lambda(typically an unbounded method reference) 417 * to be invoked on call 418 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 419 * @param arg2 parameter supplied to {@code function} on call 420 * @return a {@link PooledFunction}, equivalent to lambda: 421 * {@code (arg1) -> function(arg1, arg2) } 422 */ obtainFunction( BiFunction<? super A, ? super B, ? extends R> function, ArgumentPlaceholder<A> arg1, B arg2)423 static <A, B, R> PooledFunction<A, R> obtainFunction( 424 BiFunction<? super A, ? super B, ? extends R> function, 425 ArgumentPlaceholder<A> arg1, B arg2) { 426 return acquire(PooledLambdaImpl.sPool, 427 function, 2, 1, ReturnType.OBJECT, arg1, arg2, null, null, null, null, null, null, 428 null, null, null, null); 429 } 430 431 /** 432 * {@link PooledConsumer} factory 433 * 434 * @param function non-capturing lambda(typically an unbounded method reference) 435 * to be invoked on call 436 * @param arg1 parameter supplied to {@code function} on call 437 * @param arg2 placeholder for a missing argument. Use {@link #__} to get one 438 * @return a {@link PooledConsumer}, equivalent to lambda: 439 * {@code (arg2) -> function(arg1, arg2) } 440 */ obtainConsumer( BiConsumer<? super A, ? super B> function, A arg1, ArgumentPlaceholder<B> arg2)441 static <A, B> PooledConsumer<B> obtainConsumer( 442 BiConsumer<? super A, ? super B> function, 443 A arg1, ArgumentPlaceholder<B> arg2) { 444 return acquire(PooledLambdaImpl.sPool, 445 function, 2, 1, ReturnType.VOID, arg1, arg2, null, null, null, null, null, null, 446 null, null, null, null); 447 } 448 449 /** 450 * {@link PooledPredicate} factory 451 * 452 * @param function non-capturing lambda(typically an unbounded method reference) 453 * to be invoked on call 454 * @param arg1 parameter supplied to {@code function} on call 455 * @param arg2 placeholder for a missing argument. Use {@link #__} to get one 456 * @return a {@link PooledPredicate}, equivalent to lambda: 457 * {@code (arg2) -> function(arg1, arg2) } 458 */ obtainPredicate( BiPredicate<? super A, ? super B> function, A arg1, ArgumentPlaceholder<B> arg2)459 static <A, B> PooledPredicate<B> obtainPredicate( 460 BiPredicate<? super A, ? super B> function, 461 A arg1, ArgumentPlaceholder<B> arg2) { 462 return acquire(PooledLambdaImpl.sPool, 463 function, 2, 1, ReturnType.BOOLEAN, arg1, arg2, null, null, null, null, null, null, 464 null, null, null, null); 465 } 466 467 /** 468 * {@link PooledFunction} factory 469 * 470 * @param function non-capturing lambda(typically an unbounded method reference) 471 * to be invoked on call 472 * @param arg1 parameter supplied to {@code function} on call 473 * @param arg2 placeholder for a missing argument. Use {@link #__} to get one 474 * @return a {@link PooledFunction}, equivalent to lambda: 475 * {@code (arg2) -> function(arg1, arg2) } 476 */ obtainFunction( BiFunction<? super A, ? super B, ? extends R> function, A arg1, ArgumentPlaceholder<B> arg2)477 static <A, B, R> PooledFunction<B, R> obtainFunction( 478 BiFunction<? super A, ? super B, ? extends R> function, 479 A arg1, ArgumentPlaceholder<B> arg2) { 480 return acquire(PooledLambdaImpl.sPool, 481 function, 2, 1, ReturnType.OBJECT, arg1, arg2, null, null, null, null, null, null, 482 null, null, null, null); 483 } 484 485 /** 486 * Factory of {@link Message}s that contain an 487 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 488 * {@link Message#getCallback internal callback}. 489 * 490 * The callback is equivalent to one obtainable via 491 * {@link #obtainRunnable(BiConsumer, Object, Object)} 492 * 493 * Note that using this method with {@link android.os.Handler#handleMessage} 494 * is more efficient than the alternative of {@link android.os.Handler#post} 495 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 496 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 497 * 498 * You may optionally set a {@link Message#what} for the message if you want to be 499 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 500 * there's no need to do so 501 * 502 * @param function non-capturing lambda(typically an unbounded method reference) 503 * to be invoked on call 504 * @param arg1 parameter supplied to {@code function} on call 505 * @param arg2 parameter supplied to {@code function} on call 506 * @return a {@link Message} invoking {@code function(arg1, arg2) } when handled 507 */ obtainMessage( BiConsumer<? super A, ? super B> function, A arg1, B arg2)508 static <A, B> Message obtainMessage( 509 BiConsumer<? super A, ? super B> function, 510 A arg1, B arg2) { 511 synchronized (Message.sPoolSync) { 512 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 513 function, 2, 0, ReturnType.VOID, arg1, arg2, null, null, null, null, null, null, 514 null, null, null, null); 515 return Message.obtain().setCallback(callback.recycleOnUse()); 516 } 517 } 518 519 /** 520 * {@link PooledRunnable} factory 521 * 522 * @param function non-capturing lambda(typically an unbounded method reference) 523 * to be invoked on call 524 * @param arg1 parameter supplied to {@code function} on call 525 * @param arg2 parameter supplied to {@code function} on call 526 * @param arg3 parameter supplied to {@code function} on call 527 * @return a {@link PooledRunnable}, equivalent to lambda: 528 * {@code () -> function(arg1, arg2, arg3) } 529 */ obtainRunnable( TriConsumer<? super A, ? super B, ? super C> function, A arg1, B arg2, C arg3)530 static <A, B, C> PooledRunnable obtainRunnable( 531 TriConsumer<? super A, ? super B, ? super C> function, 532 A arg1, B arg2, C arg3) { 533 return acquire(PooledLambdaImpl.sPool, 534 function, 3, 0, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null, 535 null, null, null, null); 536 } 537 538 /** 539 * {@link PooledSupplier} factory 540 * 541 * @param function non-capturing lambda(typically an unbounded method reference) 542 * to be invoked on call 543 * @param arg1 parameter supplied to {@code function} on call 544 * @param arg2 parameter supplied to {@code function} on call 545 * @param arg3 parameter supplied to {@code function} on call 546 * @return a {@link PooledSupplier}, equivalent to lambda: 547 * {@code () -> function(arg1, arg2, arg3) } 548 */ obtainSupplier( TriFunction<? super A, ? super B, ? super C, ? extends R> function, A arg1, B arg2, C arg3)549 static <A, B, C, R> PooledSupplier<R> obtainSupplier( 550 TriFunction<? super A, ? super B, ? super C, ? extends R> function, 551 A arg1, B arg2, C arg3) { 552 return acquire(PooledLambdaImpl.sPool, 553 function, 3, 0, ReturnType.OBJECT, arg1, arg2, arg3, null, null, null, null, null, 554 null, null, null, null); 555 } 556 557 /** 558 * {@link PooledConsumer} factory 559 * 560 * @param function non-capturing lambda(typically an unbounded method reference) 561 * to be invoked on call 562 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 563 * @param arg2 parameter supplied to {@code function} on call 564 * @param arg3 parameter supplied to {@code function} on call 565 * @return a {@link PooledConsumer}, equivalent to lambda: 566 * {@code (arg1) -> function(arg1, arg2, arg3) } 567 */ obtainConsumer( TriConsumer<? super A, ? super B, ? super C> function, ArgumentPlaceholder<A> arg1, B arg2, C arg3)568 static <A, B, C> PooledConsumer<A> obtainConsumer( 569 TriConsumer<? super A, ? super B, ? super C> function, 570 ArgumentPlaceholder<A> arg1, B arg2, C arg3) { 571 return acquire(PooledLambdaImpl.sPool, 572 function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null, 573 null, null, null, null); 574 } 575 576 /** 577 * {@link PooledFunction} factory 578 * 579 * @param function non-capturing lambda(typically an unbounded method reference) 580 * to be invoked on call 581 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 582 * @param arg2 parameter supplied to {@code function} on call 583 * @param arg3 parameter supplied to {@code function} on call 584 * @return a {@link PooledFunction}, equivalent to lambda: 585 * {@code (arg1) -> function(arg1, arg2, arg3) } 586 */ obtainFunction( TriFunction<? super A, ? super B, ? super C, ? extends R> function, ArgumentPlaceholder<A> arg1, B arg2, C arg3)587 static <A, B, C, R> PooledFunction<A, R> obtainFunction( 588 TriFunction<? super A, ? super B, ? super C, ? extends R> function, 589 ArgumentPlaceholder<A> arg1, B arg2, C arg3) { 590 return acquire(PooledLambdaImpl.sPool, 591 function, 3, 1, ReturnType.OBJECT, arg1, arg2, arg3, null, null, null, null, null, 592 null, null, null, null); 593 } 594 595 /** 596 * {@link PooledConsumer} factory 597 * 598 * @param function non-capturing lambda(typically an unbounded method reference) 599 * to be invoked on call 600 * @param arg1 parameter supplied to {@code function} on call 601 * @param arg2 placeholder for a missing argument. Use {@link #__} to get one 602 * @param arg3 parameter supplied to {@code function} on call 603 * @return a {@link PooledConsumer}, equivalent to lambda: 604 * {@code (arg2) -> function(arg1, arg2, arg3) } 605 */ obtainConsumer( TriConsumer<? super A, ? super B, ? super C> function, A arg1, ArgumentPlaceholder<B> arg2, C arg3)606 static <A, B, C> PooledConsumer<B> obtainConsumer( 607 TriConsumer<? super A, ? super B, ? super C> function, 608 A arg1, ArgumentPlaceholder<B> arg2, C arg3) { 609 return acquire(PooledLambdaImpl.sPool, 610 function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null, 611 null, null, null, null); 612 } 613 614 /** 615 * {@link PooledFunction} factory 616 * 617 * @param function non-capturing lambda(typically an unbounded method reference) 618 * to be invoked on call 619 * @param arg1 parameter supplied to {@code function} on call 620 * @param arg2 placeholder for a missing argument. Use {@link #__} to get one 621 * @param arg3 parameter supplied to {@code function} on call 622 * @return a {@link PooledFunction}, equivalent to lambda: 623 * {@code (arg2) -> function(arg1, arg2, arg3) } 624 */ obtainFunction( TriFunction<? super A, ? super B, ? super C, ? extends R> function, A arg1, ArgumentPlaceholder<B> arg2, C arg3)625 static <A, B, C, R> PooledFunction<B, R> obtainFunction( 626 TriFunction<? super A, ? super B, ? super C, ? extends R> function, 627 A arg1, ArgumentPlaceholder<B> arg2, C arg3) { 628 return acquire(PooledLambdaImpl.sPool, 629 function, 3, 1, ReturnType.OBJECT, arg1, arg2, arg3, null, null, null, null, null, 630 null, null, null, null); 631 } 632 633 /** 634 * {@link PooledConsumer} factory 635 * 636 * @param function non-capturing lambda(typically an unbounded method reference) 637 * to be invoked on call 638 * @param arg1 parameter supplied to {@code function} on call 639 * @param arg2 parameter supplied to {@code function} on call 640 * @param arg3 placeholder for a missing argument. Use {@link #__} to get one 641 * @return a {@link PooledConsumer}, equivalent to lambda: 642 * {@code (arg3) -> function(arg1, arg2, arg3) } 643 */ obtainConsumer( TriConsumer<? super A, ? super B, ? super C> function, A arg1, B arg2, ArgumentPlaceholder<C> arg3)644 static <A, B, C> PooledConsumer<C> obtainConsumer( 645 TriConsumer<? super A, ? super B, ? super C> function, 646 A arg1, B arg2, ArgumentPlaceholder<C> arg3) { 647 return acquire(PooledLambdaImpl.sPool, 648 function, 3, 1, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null, 649 null, null, null, null); 650 } 651 652 /** 653 * {@link PooledFunction} factory 654 * 655 * @param function non-capturing lambda(typically an unbounded method reference) 656 * to be invoked on call 657 * @param arg1 parameter supplied to {@code function} on call 658 * @param arg2 parameter supplied to {@code function} on call 659 * @param arg3 placeholder for a missing argument. Use {@link #__} to get one 660 * @return a {@link PooledFunction}, equivalent to lambda: 661 * {@code (arg3) -> function(arg1, arg2, arg3) } 662 */ obtainFunction( TriFunction<? super A, ? super B, ? super C, ? extends R> function, A arg1, B arg2, ArgumentPlaceholder<C> arg3)663 static <A, B, C, R> PooledFunction<C, R> obtainFunction( 664 TriFunction<? super A, ? super B, ? super C, ? extends R> function, 665 A arg1, B arg2, ArgumentPlaceholder<C> arg3) { 666 return acquire(PooledLambdaImpl.sPool, 667 function, 3, 1, ReturnType.OBJECT, arg1, arg2, arg3, null, null, null, null, null, 668 null, null, null, null); 669 } 670 671 /** 672 * Factory of {@link Message}s that contain an 673 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 674 * {@link Message#getCallback internal callback}. 675 * 676 * The callback is equivalent to one obtainable via 677 * {@link #obtainRunnable(TriConsumer, Object, Object, Object)} 678 * 679 * Note that using this method with {@link android.os.Handler#handleMessage} 680 * is more efficient than the alternative of {@link android.os.Handler#post} 681 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 682 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 683 * 684 * You may optionally set a {@link Message#what} for the message if you want to be 685 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 686 * there's no need to do so 687 * 688 * @param function non-capturing lambda(typically an unbounded method reference) 689 * to be invoked on call 690 * @param arg1 parameter supplied to {@code function} on call 691 * @param arg2 parameter supplied to {@code function} on call 692 * @param arg3 parameter supplied to {@code function} on call 693 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3) } when handled 694 */ obtainMessage( TriConsumer<? super A, ? super B, ? super C> function, A arg1, B arg2, C arg3)695 static <A, B, C> Message obtainMessage( 696 TriConsumer<? super A, ? super B, ? super C> function, 697 A arg1, B arg2, C arg3) { 698 synchronized (Message.sPoolSync) { 699 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 700 function, 3, 0, ReturnType.VOID, arg1, arg2, arg3, null, null, null, null, null, 701 null, null, null, null); 702 return Message.obtain().setCallback(callback.recycleOnUse()); 703 } 704 } 705 706 /** 707 * {@link PooledRunnable} factory 708 * 709 * @param function non-capturing lambda(typically an unbounded method reference) 710 * to be invoked on call 711 * @param arg1 parameter supplied to {@code function} on call 712 * @param arg2 parameter supplied to {@code function} on call 713 * @param arg3 parameter supplied to {@code function} on call 714 * @param arg4 parameter supplied to {@code function} on call 715 * @return a {@link PooledRunnable}, equivalent to lambda: 716 * {@code () -> function(arg1, arg2, arg3, arg4) } 717 */ obtainRunnable( QuadConsumer<? super A, ? super B, ? super C, ? super D> function, A arg1, B arg2, C arg3, D arg4)718 static <A, B, C, D> PooledRunnable obtainRunnable( 719 QuadConsumer<? super A, ? super B, ? super C, ? super D> function, 720 A arg1, B arg2, C arg3, D arg4) { 721 return acquire(PooledLambdaImpl.sPool, 722 function, 4, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null, 723 null, null, null, null); 724 } 725 726 /** 727 * {@link PooledSupplier} factory 728 * 729 * @param function non-capturing lambda(typically an unbounded method reference) 730 * to be invoked on call 731 * @param arg1 parameter supplied to {@code function} on call 732 * @param arg2 parameter supplied to {@code function} on call 733 * @param arg3 parameter supplied to {@code function} on call 734 * @param arg4 parameter supplied to {@code function} on call 735 * @return a {@link PooledSupplier}, equivalent to lambda: 736 * {@code () -> function(arg1, arg2, arg3, arg4) } 737 */ obtainSupplier( QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, A arg1, B arg2, C arg3, D arg4)738 static <A, B, C, D, R> PooledSupplier<R> obtainSupplier( 739 QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, 740 A arg1, B arg2, C arg3, D arg4) { 741 return acquire(PooledLambdaImpl.sPool, 742 function, 4, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, null, null, null, null, 743 null, null, null, null); 744 } 745 746 /** 747 * {@link PooledConsumer} factory 748 * 749 * @param function non-capturing lambda(typically an unbounded method reference) 750 * to be invoked on call 751 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 752 * @param arg2 parameter supplied to {@code function} on call 753 * @param arg3 parameter supplied to {@code function} on call 754 * @param arg4 parameter supplied to {@code function} on call 755 * @return a {@link PooledConsumer}, equivalent to lambda: 756 * {@code (arg1) -> function(arg1, arg2, arg3, arg4) } 757 */ obtainConsumer( QuadConsumer<? super A, ? super B, ? super C, ? super D> function, ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4)758 static <A, B, C, D> PooledConsumer<A> obtainConsumer( 759 QuadConsumer<? super A, ? super B, ? super C, ? super D> function, 760 ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4) { 761 return acquire(PooledLambdaImpl.sPool, 762 function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null, 763 null, null, null, null); 764 } 765 766 /** 767 * {@link PooledFunction} factory 768 * 769 * @param function non-capturing lambda(typically an unbounded method reference) 770 * to be invoked on call 771 * @param arg1 placeholder for a missing argument. Use {@link #__} to get one 772 * @param arg2 parameter supplied to {@code function} on call 773 * @param arg3 parameter supplied to {@code function} on call 774 * @param arg4 parameter supplied to {@code function} on call 775 * @return a {@link PooledFunction}, equivalent to lambda: 776 * {@code (arg1) -> function(arg1, arg2, arg3, arg4) } 777 */ obtainFunction( QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4)778 static <A, B, C, D, R> PooledFunction<A, R> obtainFunction( 779 QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, 780 ArgumentPlaceholder<A> arg1, B arg2, C arg3, D arg4) { 781 return acquire(PooledLambdaImpl.sPool, 782 function, 4, 1, ReturnType.OBJECT, arg1, arg2, arg3, arg4, null, null, null, null, 783 null, null, null, null); 784 } 785 786 /** 787 * {@link PooledConsumer} factory 788 * 789 * @param function non-capturing lambda(typically an unbounded method reference) 790 * to be invoked on call 791 * @param arg1 parameter supplied to {@code function} on call 792 * @param arg2 placeholder for a missing argument. Use {@link #__} to get one 793 * @param arg3 parameter supplied to {@code function} on call 794 * @param arg4 parameter supplied to {@code function} on call 795 * @return a {@link PooledConsumer}, equivalent to lambda: 796 * {@code (arg2) -> function(arg1, arg2, arg3, arg4) } 797 */ obtainConsumer( QuadConsumer<? super A, ? super B, ? super C, ? super D> function, A arg1, ArgumentPlaceholder<B> arg2, C arg3, D arg4)798 static <A, B, C, D> PooledConsumer<B> obtainConsumer( 799 QuadConsumer<? super A, ? super B, ? super C, ? super D> function, 800 A arg1, ArgumentPlaceholder<B> arg2, C arg3, D arg4) { 801 return acquire(PooledLambdaImpl.sPool, 802 function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null, 803 null, null, null, null); 804 } 805 806 /** 807 * {@link PooledFunction} factory 808 * 809 * @param function non-capturing lambda(typically an unbounded method reference) 810 * to be invoked on call 811 * @param arg1 parameter supplied to {@code function} on call 812 * @param arg2 placeholder for a missing argument. Use {@link #__} to get one 813 * @param arg3 parameter supplied to {@code function} on call 814 * @param arg4 parameter supplied to {@code function} on call 815 * @return a {@link PooledFunction}, equivalent to lambda: 816 * {@code (arg2) -> function(arg1, arg2, arg3, arg4) } 817 */ obtainFunction( QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, A arg1, ArgumentPlaceholder<B> arg2, C arg3, D arg4)818 static <A, B, C, D, R> PooledFunction<B, R> obtainFunction( 819 QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, 820 A arg1, ArgumentPlaceholder<B> arg2, C arg3, D arg4) { 821 return acquire(PooledLambdaImpl.sPool, 822 function, 4, 1, ReturnType.OBJECT, arg1, arg2, arg3, arg4, null, null, null, null, 823 null, null, null, null); 824 } 825 826 /** 827 * {@link PooledConsumer} factory 828 * 829 * @param function non-capturing lambda(typically an unbounded method reference) 830 * to be invoked on call 831 * @param arg1 parameter supplied to {@code function} on call 832 * @param arg2 parameter supplied to {@code function} on call 833 * @param arg3 placeholder for a missing argument. Use {@link #__} to get one 834 * @param arg4 parameter supplied to {@code function} on call 835 * @return a {@link PooledConsumer}, equivalent to lambda: 836 * {@code (arg3) -> function(arg1, arg2, arg3, arg4) } 837 */ obtainConsumer( QuadConsumer<? super A, ? super B, ? super C, ? super D> function, A arg1, B arg2, ArgumentPlaceholder<C> arg3, D arg4)838 static <A, B, C, D> PooledConsumer<C> obtainConsumer( 839 QuadConsumer<? super A, ? super B, ? super C, ? super D> function, 840 A arg1, B arg2, ArgumentPlaceholder<C> arg3, D arg4) { 841 return acquire(PooledLambdaImpl.sPool, 842 function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null, 843 null, null, null, null); 844 } 845 846 /** 847 * {@link PooledFunction} factory 848 * 849 * @param function non-capturing lambda(typically an unbounded method reference) 850 * to be invoked on call 851 * @param arg1 parameter supplied to {@code function} on call 852 * @param arg2 parameter supplied to {@code function} on call 853 * @param arg3 placeholder for a missing argument. Use {@link #__} to get one 854 * @param arg4 parameter supplied to {@code function} on call 855 * @return a {@link PooledFunction}, equivalent to lambda: 856 * {@code (arg3) -> function(arg1, arg2, arg3, arg4) } 857 */ obtainFunction( QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, A arg1, B arg2, ArgumentPlaceholder<C> arg3, D arg4)858 static <A, B, C, D, R> PooledFunction<C, R> obtainFunction( 859 QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, 860 A arg1, B arg2, ArgumentPlaceholder<C> arg3, D arg4) { 861 return acquire(PooledLambdaImpl.sPool, 862 function, 4, 1, ReturnType.OBJECT, arg1, arg2, arg3, arg4, null, null, null, null, 863 null, null, null, null); 864 } 865 866 /** 867 * {@link PooledConsumer} factory 868 * 869 * @param function non-capturing lambda(typically an unbounded method reference) 870 * to be invoked on call 871 * @param arg1 parameter supplied to {@code function} on call 872 * @param arg2 parameter supplied to {@code function} on call 873 * @param arg3 parameter supplied to {@code function} on call 874 * @param arg4 placeholder for a missing argument. Use {@link #__} to get one 875 * @return a {@link PooledConsumer}, equivalent to lambda: 876 * {@code (arg4) -> function(arg1, arg2, arg3, arg4) } 877 */ obtainConsumer( QuadConsumer<? super A, ? super B, ? super C, ? super D> function, A arg1, B arg2, C arg3, ArgumentPlaceholder<D> arg4)878 static <A, B, C, D> PooledConsumer<D> obtainConsumer( 879 QuadConsumer<? super A, ? super B, ? super C, ? super D> function, 880 A arg1, B arg2, C arg3, ArgumentPlaceholder<D> arg4) { 881 return acquire(PooledLambdaImpl.sPool, 882 function, 4, 1, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null, 883 null, null, null, null); 884 } 885 886 /** 887 * {@link PooledFunction} factory 888 * 889 * @param function non-capturing lambda(typically an unbounded method reference) 890 * to be invoked on call 891 * @param arg1 parameter supplied to {@code function} on call 892 * @param arg2 parameter supplied to {@code function} on call 893 * @param arg3 parameter supplied to {@code function} on call 894 * @param arg4 placeholder for a missing argument. Use {@link #__} to get one 895 * @return a {@link PooledFunction}, equivalent to lambda: 896 * {@code (arg4) -> function(arg1, arg2, arg3, arg4) } 897 */ obtainFunction( QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, A arg1, B arg2, C arg3, ArgumentPlaceholder<D> arg4)898 static <A, B, C, D, R> PooledFunction<D, R> obtainFunction( 899 QuadFunction<? super A, ? super B, ? super C, ? super D, ? extends R> function, 900 A arg1, B arg2, C arg3, ArgumentPlaceholder<D> arg4) { 901 return acquire(PooledLambdaImpl.sPool, 902 function, 4, 1, ReturnType.OBJECT, arg1, arg2, arg3, arg4, null, null, null, null, 903 null, null, null, null); 904 } 905 906 /** 907 * Factory of {@link Message}s that contain an 908 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 909 * {@link Message#getCallback internal callback}. 910 * 911 * The callback is equivalent to one obtainable via 912 * {@link #obtainRunnable(QuadConsumer, Object, Object, Object, Object)} 913 * 914 * Note that using this method with {@link android.os.Handler#handleMessage} 915 * is more efficient than the alternative of {@link android.os.Handler#post} 916 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 917 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 918 * 919 * You may optionally set a {@link Message#what} for the message if you want to be 920 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 921 * there's no need to do so 922 * 923 * @param function non-capturing lambda(typically an unbounded method reference) 924 * to be invoked on call 925 * @param arg1 parameter supplied to {@code function} on call 926 * @param arg2 parameter supplied to {@code function} on call 927 * @param arg3 parameter supplied to {@code function} on call 928 * @param arg4 parameter supplied to {@code function} on call 929 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4) } when handled 930 */ obtainMessage( QuadConsumer<? super A, ? super B, ? super C, ? super D> function, A arg1, B arg2, C arg3, D arg4)931 static <A, B, C, D> Message obtainMessage( 932 QuadConsumer<? super A, ? super B, ? super C, ? super D> function, 933 A arg1, B arg2, C arg3, D arg4) { 934 synchronized (Message.sPoolSync) { 935 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 936 function, 4, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, null, null, null, null, 937 null, null, null, null); 938 return Message.obtain().setCallback(callback.recycleOnUse()); 939 } 940 } 941 942 /** 943 * {@link PooledRunnable} factory 944 * 945 * @param function non-capturing lambda(typically an unbounded method reference) 946 * to be invoked on call 947 * @param arg1 parameter supplied to {@code function} on call 948 * @param arg2 parameter supplied to {@code function} on call 949 * @param arg3 parameter supplied to {@code function} on call 950 * @param arg4 parameter supplied to {@code function} on call 951 * @param arg5 parameter supplied to {@code function} on call 952 * @return a {@link PooledRunnable}, equivalent to lambda: 953 * {@code () -> function(arg1, arg2, arg3, arg4, arg5) } 954 */ obtainRunnable( QuintConsumer<? super A, ? super B, ? super C, ? super D, ? super E> function, A arg1, B arg2, C arg3, D arg4, E arg5)955 static <A, B, C, D, E> PooledRunnable obtainRunnable( 956 QuintConsumer<? super A, ? super B, ? super C, ? super D, ? super E> function, 957 A arg1, B arg2, C arg3, D arg4, E arg5) { 958 return acquire(PooledLambdaImpl.sPool, 959 function, 5, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, null, null, null, 960 null, null, null, null); 961 } 962 963 /** 964 * {@link PooledSupplier} factory 965 * 966 * @param function non-capturing lambda(typically an unbounded method reference) 967 * to be invoked on call 968 * @param arg1 parameter supplied to {@code function} on call 969 * @param arg2 parameter supplied to {@code function} on call 970 * @param arg3 parameter supplied to {@code function} on call 971 * @param arg4 parameter supplied to {@code function} on call 972 * @param arg5 parameter supplied to {@code function} on call 973 * @return a {@link PooledSupplier}, equivalent to lambda: 974 * {@code () -> function(arg1, arg2, arg3, arg4, arg5) } 975 */ obtainSupplier( QuintFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5)976 static <A, B, C, D, E, R> PooledSupplier<R> obtainSupplier( 977 QuintFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? extends R> 978 function, A arg1, B arg2, C arg3, D arg4, E arg5) { 979 return acquire(PooledLambdaImpl.sPool, 980 function, 5, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, arg5, null, null, null, 981 null, null, null, null); 982 } 983 984 /** 985 * Factory of {@link Message}s that contain an 986 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 987 * {@link Message#getCallback internal callback}. 988 * 989 * The callback is equivalent to one obtainable via 990 * {@link #obtainRunnable(QuintConsumer, Object, Object, Object, Object, Object)} 991 * 992 * Note that using this method with {@link android.os.Handler#handleMessage} 993 * is more efficient than the alternative of {@link android.os.Handler#post} 994 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 995 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 996 * 997 * You may optionally set a {@link Message#what} for the message if you want to be 998 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 999 * there's no need to do so 1000 * 1001 * @param function non-capturing lambda(typically an unbounded method reference) 1002 * to be invoked on call 1003 * @param arg1 parameter supplied to {@code function} on call 1004 * @param arg2 parameter supplied to {@code function} on call 1005 * @param arg3 parameter supplied to {@code function} on call 1006 * @param arg4 parameter supplied to {@code function} on call 1007 * @param arg5 parameter supplied to {@code function} on call 1008 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4, arg5) } when 1009 * handled 1010 */ obtainMessage( QuintConsumer<? super A, ? super B, ? super C, ? super D, ? super E> function, A arg1, B arg2, C arg3, D arg4, E arg5)1011 static <A, B, C, D, E> Message obtainMessage( 1012 QuintConsumer<? super A, ? super B, ? super C, ? super D, ? super E> function, 1013 A arg1, B arg2, C arg3, D arg4, E arg5) { 1014 synchronized (Message.sPoolSync) { 1015 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 1016 function, 5, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, null, null, null, 1017 null, null, null, null); 1018 return Message.obtain().setCallback(callback.recycleOnUse()); 1019 } 1020 } 1021 1022 /** 1023 * {@link PooledRunnable} factory 1024 * 1025 * @param function non-capturing lambda(typically an unbounded method reference) 1026 * to be invoked on call 1027 * @param arg1 parameter supplied to {@code function} on call 1028 * @param arg2 parameter supplied to {@code function} on call 1029 * @param arg3 parameter supplied to {@code function} on call 1030 * @param arg4 parameter supplied to {@code function} on call 1031 * @param arg5 parameter supplied to {@code function} on call 1032 * @param arg6 parameter supplied to {@code function} on call 1033 * @return a {@link PooledRunnable}, equivalent to lambda: 1034 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6) } 1035 */ obtainRunnable( HexConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6)1036 static <A, B, C, D, E, F> PooledRunnable obtainRunnable( 1037 HexConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F> function, 1038 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6) { 1039 return acquire(PooledLambdaImpl.sPool, 1040 function, 6, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, null, null, 1041 null, null, null, null); 1042 } 1043 1044 /** 1045 * {@link PooledSupplier} factory 1046 * 1047 * @param function non-capturing lambda(typically an unbounded method reference) 1048 * to be invoked on call 1049 * @param arg1 parameter supplied to {@code function} on call 1050 * @param arg2 parameter supplied to {@code function} on call 1051 * @param arg3 parameter supplied to {@code function} on call 1052 * @param arg4 parameter supplied to {@code function} on call 1053 * @param arg5 parameter supplied to {@code function} on call 1054 * @param arg6 parameter supplied to {@code function} on call 1055 * @return a {@link PooledSupplier}, equivalent to lambda: 1056 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6) } 1057 */ obtainSupplier( HexFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6)1058 static <A, B, C, D, E, F, R> PooledSupplier<R> obtainSupplier( 1059 HexFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1060 ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6) { 1061 return acquire(PooledLambdaImpl.sPool, 1062 function, 6, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, arg5, arg6, null, null, 1063 null, null, null, null); 1064 } 1065 1066 /** 1067 * Factory of {@link Message}s that contain an 1068 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 1069 * {@link Message#getCallback internal callback}. 1070 * 1071 * The callback is equivalent to one obtainable via 1072 * {@link #obtainRunnable(QuintConsumer, Object, Object, Object, Object, Object)} 1073 * 1074 * Note that using this method with {@link android.os.Handler#handleMessage} 1075 * is more efficient than the alternative of {@link android.os.Handler#post} 1076 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 1077 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 1078 * 1079 * You may optionally set a {@link Message#what} for the message if you want to be 1080 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 1081 * there's no need to do so 1082 * 1083 * @param function non-capturing lambda(typically an unbounded method reference) 1084 * to be invoked on call 1085 * @param arg1 parameter supplied to {@code function} on call 1086 * @param arg2 parameter supplied to {@code function} on call 1087 * @param arg3 parameter supplied to {@code function} on call 1088 * @param arg4 parameter supplied to {@code function} on call 1089 * @param arg5 parameter supplied to {@code function} on call 1090 * @param arg6 parameter supplied to {@code function} on call 1091 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4, arg5, arg6) } 1092 * when handled 1093 */ obtainMessage( HexConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6)1094 static <A, B, C, D, E, F> Message obtainMessage( 1095 HexConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F> function, 1096 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6) { 1097 synchronized (Message.sPoolSync) { 1098 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 1099 function, 6, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, null, null, 1100 null, null, null, null); 1101 return Message.obtain().setCallback(callback.recycleOnUse()); 1102 } 1103 } 1104 1105 /** 1106 * {@link PooledRunnable} factory 1107 * 1108 * @param function non-capturing lambda(typically an unbounded method reference) 1109 * to be invoked on call 1110 * @param arg1 parameter supplied to {@code function} on call 1111 * @param arg2 parameter supplied to {@code function} on call 1112 * @param arg3 parameter supplied to {@code function} on call 1113 * @param arg4 parameter supplied to {@code function} on call 1114 * @param arg5 parameter supplied to {@code function} on call 1115 * @param arg6 parameter supplied to {@code function} on call 1116 * @param arg7 parameter supplied to {@code function} on call 1117 * @return a {@link PooledRunnable}, equivalent to lambda: 1118 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7) } 1119 */ obtainRunnable( HeptConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7)1120 static <A, B, C, D, E, F, G> PooledRunnable obtainRunnable( 1121 HeptConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1122 ? super G> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7) { 1123 return acquire(PooledLambdaImpl.sPool, 1124 function, 7, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, null, 1125 null, null, null, null); 1126 } 1127 1128 /** 1129 * {@link PooledSupplier} factory 1130 * 1131 * @param function non-capturing lambda(typically an unbounded method reference) 1132 * to be invoked on call 1133 * @param arg1 parameter supplied to {@code function} on call 1134 * @param arg2 parameter supplied to {@code function} on call 1135 * @param arg3 parameter supplied to {@code function} on call 1136 * @param arg4 parameter supplied to {@code function} on call 1137 * @param arg5 parameter supplied to {@code function} on call 1138 * @param arg6 parameter supplied to {@code function} on call 1139 * @param arg7 parameter supplied to {@code function} on call 1140 * @return a {@link PooledSupplier}, equivalent to lambda: 1141 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7) } 1142 */ obtainSupplier( HeptFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7)1143 static <A, B, C, D, E, F, G, R> PooledSupplier<R> obtainSupplier( 1144 HeptFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1145 ? super G, ? extends R> function, 1146 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7) { 1147 return acquire(PooledLambdaImpl.sPool, 1148 function, 7, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, arg5, arg6, arg7, null, 1149 null, null, null, null); 1150 } 1151 1152 /** 1153 * Factory of {@link Message}s that contain an 1154 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 1155 * {@link Message#getCallback internal callback}. 1156 * 1157 * The callback is equivalent to one obtainable via 1158 * {@link #obtainRunnable(QuintConsumer, Object, Object, Object, Object, Object)} 1159 * 1160 * Note that using this method with {@link android.os.Handler#handleMessage} 1161 * is more efficient than the alternative of {@link android.os.Handler#post} 1162 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 1163 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 1164 * 1165 * You may optionally set a {@link Message#what} for the message if you want to be 1166 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 1167 * there's no need to do so 1168 * 1169 * @param function non-capturing lambda(typically an unbounded method reference) 1170 * to be invoked on call 1171 * @param arg1 parameter supplied to {@code function} on call 1172 * @param arg2 parameter supplied to {@code function} on call 1173 * @param arg3 parameter supplied to {@code function} on call 1174 * @param arg4 parameter supplied to {@code function} on call 1175 * @param arg5 parameter supplied to {@code function} on call 1176 * @param arg6 parameter supplied to {@code function} on call 1177 * @param arg7 parameter supplied to {@code function} on call 1178 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4, arg5, arg6, 1179 * arg7) } when handled 1180 */ obtainMessage( HeptConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7)1181 static <A, B, C, D, E, F, G> Message obtainMessage( 1182 HeptConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1183 ? super G> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7) { 1184 synchronized (Message.sPoolSync) { 1185 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 1186 function, 7, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, null, 1187 null, null, null, null); 1188 return Message.obtain().setCallback(callback.recycleOnUse()); 1189 } 1190 } 1191 1192 /** 1193 * {@link PooledRunnable} factory 1194 * 1195 * @param function non-capturing lambda(typically an unbounded method reference) 1196 * to be invoked on call 1197 * @param arg1 parameter supplied to {@code function} on call 1198 * @param arg2 parameter supplied to {@code function} on call 1199 * @param arg3 parameter supplied to {@code function} on call 1200 * @param arg4 parameter supplied to {@code function} on call 1201 * @param arg5 parameter supplied to {@code function} on call 1202 * @param arg6 parameter supplied to {@code function} on call 1203 * @param arg7 parameter supplied to {@code function} on call 1204 * @param arg8 parameter supplied to {@code function} on call 1205 * @return a {@link PooledRunnable}, equivalent to lambda: 1206 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) } 1207 */ obtainRunnable( OctConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8)1208 static <A, B, C, D, E, F, G, H> PooledRunnable obtainRunnable( 1209 OctConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, 1210 ? super H> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, 1211 H arg8) { 1212 return acquire(PooledLambdaImpl.sPool, 1213 function, 8, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1214 null, null, null, null); 1215 } 1216 1217 /** 1218 * {@link PooledSupplier} factory 1219 * 1220 * @param function non-capturing lambda(typically an unbounded method reference) 1221 * to be invoked on call 1222 * @param arg1 parameter supplied to {@code function} on call 1223 * @param arg2 parameter supplied to {@code function} on call 1224 * @param arg3 parameter supplied to {@code function} on call 1225 * @param arg4 parameter supplied to {@code function} on call 1226 * @param arg5 parameter supplied to {@code function} on call 1227 * @param arg6 parameter supplied to {@code function} on call 1228 * @param arg7 parameter supplied to {@code function} on call 1229 * @param arg8 parameter supplied to {@code function} on call 1230 * @return a {@link PooledSupplier}, equivalent to lambda: 1231 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) } 1232 */ obtainSupplier( OctFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8)1233 static <A, B, C, D, E, F, G, H, R> PooledSupplier<R> obtainSupplier( 1234 OctFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1235 ? super G, ? super H, ? extends R> function, 1236 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8) { 1237 return acquire(PooledLambdaImpl.sPool, 1238 function, 8, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1239 null, null, null, null); 1240 } 1241 1242 /** 1243 * Factory of {@link Message}s that contain an 1244 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 1245 * {@link Message#getCallback internal callback}. 1246 * 1247 * The callback is equivalent to one obtainable via 1248 * {@link #obtainRunnable(QuintConsumer, Object, Object, Object, Object, Object)} 1249 * 1250 * Note that using this method with {@link android.os.Handler#handleMessage} 1251 * is more efficient than the alternative of {@link android.os.Handler#post} 1252 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 1253 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 1254 * 1255 * You may optionally set a {@link Message#what} for the message if you want to be 1256 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 1257 * there's no need to do so 1258 * 1259 * @param function non-capturing lambda(typically an unbounded method reference) 1260 * to be invoked on call 1261 * @param arg1 parameter supplied to {@code function} on call 1262 * @param arg2 parameter supplied to {@code function} on call 1263 * @param arg3 parameter supplied to {@code function} on call 1264 * @param arg4 parameter supplied to {@code function} on call 1265 * @param arg5 parameter supplied to {@code function} on call 1266 * @param arg6 parameter supplied to {@code function} on call 1267 * @param arg7 parameter supplied to {@code function} on call 1268 * @param arg8 parameter supplied to {@code function} on call 1269 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4, arg5, arg6, 1270 * arg7, arg8) } when handled 1271 */ obtainMessage( OctConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8)1272 static <A, B, C, D, E, F, G, H> Message obtainMessage( 1273 OctConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, 1274 ? super H> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, 1275 H arg8) { 1276 synchronized (Message.sPoolSync) { 1277 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 1278 function, 8, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1279 null, null, null, null); 1280 return Message.obtain().setCallback(callback.recycleOnUse()); 1281 } 1282 } 1283 1284 /** 1285 * {@link PooledRunnable} factory 1286 * 1287 * @param function non-capturing lambda(typically an unbounded method reference) 1288 * to be invoked on call 1289 * @param arg1 parameter supplied to {@code function} on call 1290 * @param arg2 parameter supplied to {@code function} on call 1291 * @param arg3 parameter supplied to {@code function} on call 1292 * @param arg4 parameter supplied to {@code function} on call 1293 * @param arg5 parameter supplied to {@code function} on call 1294 * @param arg6 parameter supplied to {@code function} on call 1295 * @param arg7 parameter supplied to {@code function} on call 1296 * @param arg8 parameter supplied to {@code function} on call 1297 * @param arg9 parameter supplied to {@code function} on call 1298 * @return a {@link PooledRunnable}, equivalent to lambda: 1299 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) } 1300 */ obtainRunnable( NonaConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9)1301 static <A, B, C, D, E, F, G, H, I> PooledRunnable obtainRunnable( 1302 NonaConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1303 ? super G, ? super H, ? super I> function, A arg1, B arg2, C arg3, D arg4, 1304 E arg5, F arg6, G arg7, H arg8, I arg9) { 1305 return acquire(PooledLambdaImpl.sPool, 1306 function, 9, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1307 arg9, null, null, null); 1308 } 1309 1310 /** 1311 * {@link PooledSupplier} factory 1312 * 1313 * @param function non-capturing lambda(typically an unbounded method reference) 1314 * to be invoked on call 1315 * @param arg1 parameter supplied to {@code function} on call 1316 * @param arg2 parameter supplied to {@code function} on call 1317 * @param arg3 parameter supplied to {@code function} on call 1318 * @param arg4 parameter supplied to {@code function} on call 1319 * @param arg5 parameter supplied to {@code function} on call 1320 * @param arg6 parameter supplied to {@code function} on call 1321 * @param arg7 parameter supplied to {@code function} on call 1322 * @param arg8 parameter supplied to {@code function} on call 1323 * @param arg9 parameter supplied to {@code function} on call 1324 * @return a {@link PooledSupplier}, equivalent to lambda: 1325 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) } 1326 */ obtainSupplier( NonaFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9)1327 static <A, B, C, D, E, F, G, H, I, R> PooledSupplier<R> obtainSupplier( 1328 NonaFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1329 ? super G, ? super H, ? super I, ? extends R> function, 1330 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9) { 1331 return acquire(PooledLambdaImpl.sPool, 1332 function, 9, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1333 arg9, null, null, null); 1334 } 1335 1336 /** 1337 * Factory of {@link Message}s that contain an 1338 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 1339 * {@link Message#getCallback internal callback}. 1340 * 1341 * The callback is equivalent to one obtainable via 1342 * {@link #obtainRunnable(QuintConsumer, Object, Object, Object, Object, Object)} 1343 * 1344 * Note that using this method with {@link android.os.Handler#handleMessage} 1345 * is more efficient than the alternative of {@link android.os.Handler#post} 1346 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 1347 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 1348 * 1349 * You may optionally set a {@link Message#what} for the message if you want to be 1350 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 1351 * there's no need to do so 1352 * 1353 * @param function non-capturing lambda(typically an unbounded method reference) 1354 * to be invoked on call 1355 * @param arg1 parameter supplied to {@code function} on call 1356 * @param arg2 parameter supplied to {@code function} on call 1357 * @param arg3 parameter supplied to {@code function} on call 1358 * @param arg4 parameter supplied to {@code function} on call 1359 * @param arg5 parameter supplied to {@code function} on call 1360 * @param arg6 parameter supplied to {@code function} on call 1361 * @param arg7 parameter supplied to {@code function} on call 1362 * @param arg8 parameter supplied to {@code function} on call 1363 * @param arg9 parameter supplied to {@code function} on call 1364 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4, arg5, arg6, 1365 * arg7, arg8, arg9) } when handled 1366 */ obtainMessage( NonaConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9)1367 static <A, B, C, D, E, F, G, H, I> Message obtainMessage( 1368 NonaConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1369 ? super G, ? super H, ? super I> function, A arg1, B arg2, C arg3, D arg4, 1370 E arg5, F arg6, G arg7, H arg8, I arg9) { 1371 synchronized (Message.sPoolSync) { 1372 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 1373 function, 9, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1374 arg9, null, null, null); 1375 return Message.obtain().setCallback(callback.recycleOnUse()); 1376 } 1377 } 1378 1379 /** 1380 * {@link PooledRunnable} factory 1381 * 1382 * @param function non-capturing lambda(typically an unbounded method reference) 1383 * to be invoked on call 1384 * @param arg1 parameter supplied to {@code function} on call 1385 * @param arg2 parameter supplied to {@code function} on call 1386 * @param arg3 parameter supplied to {@code function} on call 1387 * @param arg4 parameter supplied to {@code function} on call 1388 * @param arg5 parameter supplied to {@code function} on call 1389 * @param arg6 parameter supplied to {@code function} on call 1390 * @param arg7 parameter supplied to {@code function} on call 1391 * @param arg8 parameter supplied to {@code function} on call 1392 * @param arg9 parameter supplied to {@code function} on call 1393 * @param arg10 parameter supplied to {@code function} on call 1394 * @return a {@link PooledRunnable}, equivalent to lambda: 1395 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) } 1396 */ obtainRunnable( DecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10)1397 static <A, B, C, D, E, F, G, H, I, J> PooledRunnable obtainRunnable( 1398 DecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1399 ? super G, ? super H, ? super I, ? super J> function, A arg1, B arg2, C arg3, 1400 D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10) { 1401 return acquire(PooledLambdaImpl.sPool, 1402 function, 10, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1403 arg9, arg10, null, null); 1404 } 1405 1406 /** 1407 * {@link PooledSupplier} factory 1408 * 1409 * @param function non-capturing lambda(typically an unbounded method reference) 1410 * to be invoked on call 1411 * @param arg1 parameter supplied to {@code function} on call 1412 * @param arg2 parameter supplied to {@code function} on call 1413 * @param arg3 parameter supplied to {@code function} on call 1414 * @param arg4 parameter supplied to {@code function} on call 1415 * @param arg5 parameter supplied to {@code function} on call 1416 * @param arg6 parameter supplied to {@code function} on call 1417 * @param arg7 parameter supplied to {@code function} on call 1418 * @param arg8 parameter supplied to {@code function} on call 1419 * @param arg9 parameter supplied to {@code function} on call 1420 * @param arg10 parameter supplied to {@code function} on call 1421 * @return a {@link PooledSupplier}, equivalent to lambda: 1422 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) } 1423 */ obtainSupplier( DecFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J, ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10)1424 static <A, B, C, D, E, F, G, H, I, J, R> PooledSupplier<R> obtainSupplier( 1425 DecFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1426 ? super G, ? super H, ? super I, ? super J, ? extends R> function, 1427 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10) { 1428 return acquire(PooledLambdaImpl.sPool, 1429 function, 10, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1430 arg9, arg10, null, null); 1431 } 1432 1433 /** 1434 * Factory of {@link Message}s that contain an 1435 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 1436 * {@link Message#getCallback internal callback}. 1437 * 1438 * The callback is equivalent to one obtainable via 1439 * {@link #obtainRunnable(QuintConsumer, Object, Object, Object, Object, Object)} 1440 * 1441 * Note that using this method with {@link android.os.Handler#handleMessage} 1442 * is more efficient than the alternative of {@link android.os.Handler#post} 1443 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 1444 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 1445 * 1446 * You may optionally set a {@link Message#what} for the message if you want to be 1447 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 1448 * there's no need to do so 1449 * 1450 * @param function non-capturing lambda(typically an unbounded method reference) 1451 * to be invoked on call 1452 * @param arg1 parameter supplied to {@code function} on call 1453 * @param arg2 parameter supplied to {@code function} on call 1454 * @param arg3 parameter supplied to {@code function} on call 1455 * @param arg4 parameter supplied to {@code function} on call 1456 * @param arg5 parameter supplied to {@code function} on call 1457 * @param arg6 parameter supplied to {@code function} on call 1458 * @param arg7 parameter supplied to {@code function} on call 1459 * @param arg8 parameter supplied to {@code function} on call 1460 * @param arg9 parameter supplied to {@code function} on call 1461 * @param arg10 parameter supplied to {@code function} on call 1462 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4, arg5, arg6, 1463 * arg7, arg8, arg9, arg10) } when handled 1464 */ obtainMessage( DecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10)1465 static <A, B, C, D, E, F, G, H, I, J> Message obtainMessage( 1466 DecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1467 ? super G, ? super H, ? super I, ? super J> function, A arg1, B arg2, C arg3, 1468 D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10) { 1469 synchronized (Message.sPoolSync) { 1470 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 1471 function, 10, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, 1472 arg8, arg9, arg10, null, null); 1473 return Message.obtain().setCallback(callback.recycleOnUse()); 1474 } 1475 } 1476 1477 /** 1478 * {@link PooledRunnable} factory 1479 * 1480 * @param function non-capturing lambda(typically an unbounded method reference) 1481 * to be invoked on call 1482 * @param arg1 parameter supplied to {@code function} on call 1483 * @param arg2 parameter supplied to {@code function} on call 1484 * @param arg3 parameter supplied to {@code function} on call 1485 * @param arg4 parameter supplied to {@code function} on call 1486 * @param arg5 parameter supplied to {@code function} on call 1487 * @param arg6 parameter supplied to {@code function} on call 1488 * @param arg7 parameter supplied to {@code function} on call 1489 * @param arg8 parameter supplied to {@code function} on call 1490 * @param arg9 parameter supplied to {@code function} on call 1491 * @param arg10 parameter supplied to {@code function} on call 1492 * @param arg11 parameter supplied to {@code function} on call 1493 * @return a {@link PooledRunnable}, equivalent to lambda: 1494 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, 1495 * arg11) } 1496 */ obtainRunnable( UndecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J, ? super K> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, K arg11)1497 static <A, B, C, D, E, F, G, H, I, J, K> PooledRunnable obtainRunnable( 1498 UndecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1499 ? super G, ? super H, ? super I, ? super J, ? super K> function, A arg1, B arg2, 1500 C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, K arg11) { 1501 return acquire(PooledLambdaImpl.sPool, 1502 function, 11, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1503 arg9, arg10, arg11, null); 1504 } 1505 1506 /** 1507 * {@link PooledSupplier} factory 1508 * 1509 * @param function non-capturing lambda(typically an unbounded method reference) 1510 * to be invoked on call 1511 * @param arg1 parameter supplied to {@code function} on call 1512 * @param arg2 parameter supplied to {@code function} on call 1513 * @param arg3 parameter supplied to {@code function} on call 1514 * @param arg4 parameter supplied to {@code function} on call 1515 * @param arg5 parameter supplied to {@code function} on call 1516 * @param arg6 parameter supplied to {@code function} on call 1517 * @param arg7 parameter supplied to {@code function} on call 1518 * @param arg8 parameter supplied to {@code function} on call 1519 * @param arg9 parameter supplied to {@code function} on call 1520 * @param arg10 parameter supplied to {@code function} on call 1521 * @param arg11 parameter supplied to {@code function} on call 1522 * @return a {@link PooledSupplier}, equivalent to lambda: 1523 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, 1524 * arg11) } 1525 */ obtainSupplier( UndecFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J, ? super K, ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, K arg11)1526 static <A, B, C, D, E, F, G, H, I, J, K, R> PooledSupplier<R> obtainSupplier( 1527 UndecFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1528 ? super G, ? super H, ? super I, ? super J, ? super K, ? extends R> function, 1529 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, 1530 K arg11) { 1531 return acquire(PooledLambdaImpl.sPool, 1532 function, 11, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1533 arg9, arg10, arg11, null); 1534 } 1535 1536 /** 1537 * Factory of {@link Message}s that contain an 1538 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 1539 * {@link Message#getCallback internal callback}. 1540 * 1541 * The callback is equivalent to one obtainable via 1542 * {@link #obtainRunnable(QuintConsumer, Object, Object, Object, Object, Object)} 1543 * 1544 * Note that using this method with {@link android.os.Handler#handleMessage} 1545 * is more efficient than the alternative of {@link android.os.Handler#post} 1546 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 1547 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 1548 * 1549 * You may optionally set a {@link Message#what} for the message if you want to be 1550 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 1551 * there's no need to do so 1552 * 1553 * @param function non-capturing lambda(typically an unbounded method reference) 1554 * to be invoked on call 1555 * @param arg1 parameter supplied to {@code function} on call 1556 * @param arg2 parameter supplied to {@code function} on call 1557 * @param arg3 parameter supplied to {@code function} on call 1558 * @param arg4 parameter supplied to {@code function} on call 1559 * @param arg5 parameter supplied to {@code function} on call 1560 * @param arg6 parameter supplied to {@code function} on call 1561 * @param arg7 parameter supplied to {@code function} on call 1562 * @param arg8 parameter supplied to {@code function} on call 1563 * @param arg9 parameter supplied to {@code function} on call 1564 * @param arg10 parameter supplied to {@code function} on call 1565 * @param arg11 parameter supplied to {@code function} on call 1566 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4, arg5, arg6, 1567 * arg7, arg8, arg9, arg10, arg11) } when handled 1568 */ obtainMessage( UndecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J, ? super K> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, K arg11)1569 static <A, B, C, D, E, F, G, H, I, J, K> Message obtainMessage( 1570 UndecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1571 ? super G, ? super H, ? super I, ? super J, ? super K> function, A arg1, B arg2, 1572 C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, K arg11) { 1573 synchronized (Message.sPoolSync) { 1574 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 1575 function, 11, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, 1576 arg8, arg9, arg10, arg11, null); 1577 return Message.obtain().setCallback(callback.recycleOnUse()); 1578 } 1579 } 1580 1581 /** 1582 * {@link PooledRunnable} factory 1583 * 1584 * @param function non-capturing lambda(typically an unbounded method reference) 1585 * to be invoked on call 1586 * @param arg1 parameter supplied to {@code function} on call 1587 * @param arg2 parameter supplied to {@code function} on call 1588 * @param arg3 parameter supplied to {@code function} on call 1589 * @param arg4 parameter supplied to {@code function} on call 1590 * @param arg5 parameter supplied to {@code function} on call 1591 * @param arg6 parameter supplied to {@code function} on call 1592 * @param arg7 parameter supplied to {@code function} on call 1593 * @param arg8 parameter supplied to {@code function} on call 1594 * @param arg9 parameter supplied to {@code function} on call 1595 * @param arg10 parameter supplied to {@code function} on call 1596 * @param arg11 parameter supplied to {@code function} on call 1597 * @param arg12 parameter supplied to {@code function} on call 1598 * @return a {@link PooledRunnable}, equivalent to lambda: 1599 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, 1600 * arg11, arg12) } 1601 */ obtainRunnable( DodecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J, ? super K, ? super L> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, K arg11, L arg12)1602 static <A, B, C, D, E, F, G, H, I, J, K, L> PooledRunnable obtainRunnable( 1603 DodecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1604 ? super G, ? super H, ? super I, ? super J, ? super K, 1605 ? super L> function, 1606 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, 1607 K arg11, L arg12) { 1608 return acquire(PooledLambdaImpl.sPool, 1609 function, 12, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1610 arg9, arg10, arg11, arg12); 1611 } 1612 1613 /** 1614 * {@link PooledSupplier} factory 1615 * 1616 * @param function non-capturing lambda(typically an unbounded method reference) 1617 * to be invoked on call 1618 * @param arg1 parameter supplied to {@code function} on call 1619 * @param arg2 parameter supplied to {@code function} on call 1620 * @param arg3 parameter supplied to {@code function} on call 1621 * @param arg4 parameter supplied to {@code function} on call 1622 * @param arg5 parameter supplied to {@code function} on call 1623 * @param arg6 parameter supplied to {@code function} on call 1624 * @param arg7 parameter supplied to {@code function} on call 1625 * @param arg8 parameter supplied to {@code function} on call 1626 * @param arg9 parameter supplied to {@code function} on call 1627 * @param arg10 parameter supplied to {@code function} on call 1628 * @param arg11 parameter supplied to {@code function} on call 1629 * @param arg12 parameter supplied to {@code function} on call 1630 * @return a {@link PooledSupplier}, equivalent to lambda: 1631 * {@code () -> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, 1632 * arg11) } 1633 */ obtainSupplier( DodecFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J, ? super K, ? extends L, ? extends R> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, K arg11, L arg12)1634 static <A, B, C, D, E, F, G, H, I, J, K, L, R> PooledSupplier<R> obtainSupplier( 1635 DodecFunction<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1636 ? super G, ? super H, ? super I, ? super J, ? super K, ? extends L, 1637 ? extends R> function, 1638 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, 1639 K arg11, L arg12) { 1640 return acquire(PooledLambdaImpl.sPool, 1641 function, 11, 0, ReturnType.OBJECT, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 1642 arg9, arg10, arg11, arg12); 1643 } 1644 1645 /** 1646 * Factory of {@link Message}s that contain an 1647 * ({@link PooledLambda#recycleOnUse auto-recycling}) {@link PooledRunnable} as its 1648 * {@link Message#getCallback internal callback}. 1649 * 1650 * The callback is equivalent to one obtainable via 1651 * {@link #obtainRunnable(QuintConsumer, Object, Object, Object, Object, Object)} 1652 * 1653 * Note that using this method with {@link android.os.Handler#handleMessage} 1654 * is more efficient than the alternative of {@link android.os.Handler#post} 1655 * with a {@link PooledRunnable} due to the lack of 2 separate synchronization points 1656 * when obtaining {@link Message} and {@link PooledRunnable} from pools separately 1657 * 1658 * You may optionally set a {@link Message#what} for the message if you want to be 1659 * able to cancel it via {@link android.os.Handler#removeMessages}, but otherwise 1660 * there's no need to do so 1661 * 1662 * @param function non-capturing lambda(typically an unbounded method reference) 1663 * to be invoked on call 1664 * @param arg1 parameter supplied to {@code function} on call 1665 * @param arg2 parameter supplied to {@code function} on call 1666 * @param arg3 parameter supplied to {@code function} on call 1667 * @param arg4 parameter supplied to {@code function} on call 1668 * @param arg5 parameter supplied to {@code function} on call 1669 * @param arg6 parameter supplied to {@code function} on call 1670 * @param arg7 parameter supplied to {@code function} on call 1671 * @param arg8 parameter supplied to {@code function} on call 1672 * @param arg9 parameter supplied to {@code function} on call 1673 * @param arg10 parameter supplied to {@code function} on call 1674 * @param arg11 parameter supplied to {@code function} on call 1675 * @param arg12 parameter supplied to {@code function} on call 1676 * @return a {@link Message} invoking {@code function(arg1, arg2, arg3, arg4, arg5, arg6, 1677 * arg7, arg8, arg9, arg10, arg11) } when handled 1678 */ obtainMessage( DodecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, ? super G, ? super H, ? super I, ? super J, ? super K, ? super L> function, A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, K arg11, L arg12)1679 static <A, B, C, D, E, F, G, H, I, J, K, L> Message obtainMessage( 1680 DodecConsumer<? super A, ? super B, ? super C, ? super D, ? super E, ? super F, 1681 ? super G, ? super H, ? super I, ? super J, ? super K, ? super L> function, 1682 A arg1, B arg2, C arg3, D arg4, E arg5, F arg6, G arg7, H arg8, I arg9, J arg10, 1683 K arg11, L arg12) { 1684 synchronized (Message.sPoolSync) { 1685 PooledRunnable callback = acquire(PooledLambdaImpl.sMessageCallbacksPool, 1686 function, 11, 0, ReturnType.VOID, arg1, arg2, arg3, arg4, arg5, arg6, arg7, 1687 arg8, arg9, arg10, arg11, arg12); 1688 return Message.obtain().setCallback(callback.recycleOnUse()); 1689 } 1690 } 1691 } 1692