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