Class AgentConcurrencyUtilHooks

java.lang.Object
se.deversity.asynctest.AgentConcurrencyUtilHooks

public final class AgentConcurrencyUtilHooks extends Object
Hooks for the java.util.concurrent coordination primitives.

Why these need the agent

A Semaphore whose permits leak, a CountDownLatch counted down the wrong number of times, a BlockingQueue whose offer silently returned false: each is a bug the library has had a detector for throughout, and each detector could only see it if the test author called a record method by hand. These are not types a test author thinks to instrument - they are plumbing, used deep inside the class under test.

Why sharing is not the question here

Unlike the shared-instance family, sharing is the whole point of these objects: a latch nobody shares does nothing. What the detectors report is misuse of the protocol, so the hooks record the operation and its outcome rather than the instance alone. That is also why the return values matter: the boolean an offer discards is the entire finding.

Ordering

Acquisition and release follow the rule AgentLockHooks sets - record after acquiring and before releasing, so the recorded interval is contained by the real one. A call that throws records nothing, because nothing happened.

The same rule feeds HappensBefore: a release and a countDown release the primitive before the call, an acquire that took a permit and an await that reached zero acquire it after, which are the edges the java.util.concurrent memory consistency effects name. The queue hand-offs reach the model through the ownership events. The CompletableFuture, Future, ExecutorService and Exchanger hooks exist for the model alone (#741), and follow the same rule: release before the call, withdraw a release the call refused, acquire after a call that returned.

Since:
1.10.0
  • Method Details

    • abaSlot

      public static @Nullable ABAProblemDetector.AgentSlot abaSlot(Object atomic)
      Returns the calling thread's ABAProblemDetector view of atomic, or null when no test with that detector runs on this thread. (#817)

      Not a substitution: the AtomicReference hooks in TelemetryRegistry ask it before each woven operation, and run the operation through the answer when there is one.

      Parameters:
      atomic - the atomic a woven call site invoked
      Returns:
      the calling thread's ABAProblemDetector view of atomic, or null when no test with that detector runs on this thread
      Since:
      1.12.3
    • abaSlot

      public static @Nullable ABAProblemDetector.AgentSlot abaSlot(Object holder, Object selector)
      Returns the calling thread's ABAProblemDetector view of the reference field selector reaches inside holder, or null when no test with that detector runs on this thread. (#817)

      For the AtomicReferenceFieldUpdater and VarHandle hooks in TelemetryRegistry, which perform their operation under the view's monitor.

      Parameters:
      holder - the object whose field is the slot
      selector - the updater or handle the call site invoked
      Returns:
      the calling thread's ABAProblemDetector view of the reference field selector reaches inside holder, or null when no test with that detector runs on this thread
      Since:
      1.12.4
    • abaSlot

      public static @Nullable ABAProblemDetector.AgentSlot abaSlot(Object array, int index)
      Returns the calling thread's ABAProblemDetector view of element index of array, or null when no test with that detector runs on this thread. (#817)
      Parameters:
      array - the AtomicReferenceArray, or the array a VarHandle reaches
      index - the element's index
      Returns:
      the calling thread's ABAProblemDetector view of element index of array, or null when no test with that detector runs on this thread
      Since:
      1.12.4
    • acquire

      public static void acquire(Semaphore receiver) throws InterruptedException
      Weaves Semaphore.acquire().
      Parameters:
      receiver - the semaphore
      Throws:
      InterruptedException - if interrupted while waiting
    • tryAcquire

      public static boolean tryAcquire(Semaphore receiver)
      Weaves Semaphore.tryAcquire().
      Parameters:
      receiver - the semaphore
      Returns:
      whether a permit was taken
    • futureTaskRun

      public static void futureTaskRun(FutureTask<Object> receiver)
      Weaves FutureTask.run() called by the code under test, the Memoizer idiom, where no executor wraps the task: when the run ends, what the callable did is released to the task, and a woven get that observed the completion acquires it (#1307).
      Parameters:
      receiver - the task the caller runs on its own thread
    • release

      public static void release(Semaphore receiver)
      Weaves Semaphore.release().
      Parameters:
      receiver - the semaphore
    • acquire

      public static void acquire(Semaphore receiver, int permits) throws InterruptedException
      Weaves Semaphore.acquire(int).

      The permit-count overloads matter more than they look. The detector's finding is a balance - acquisitions against releases - so a semaphore used as acquire(3) then release(1) leaks two permits, and recording one event for each call would have made that read as balanced. Each permit is therefore recorded separately, which is what keeps the arithmetic meaning what it says. None of these overloads was woven at all before (#434), so a pool sized in permits was invisible.

      Parameters:
      receiver - the semaphore
      permits - how many permits to take
      Throws:
      InterruptedException - if interrupted while waiting
    • tryAcquire

      public static boolean tryAcquire(Semaphore receiver, int permits)
      Weaves Semaphore.tryAcquire(int).
      Parameters:
      receiver - the semaphore
      permits - how many permits to take
      Returns:
      whether they were taken
    • tryAcquire

      public static boolean tryAcquire(Semaphore receiver, long timeout, TimeUnit unit) throws InterruptedException
      Weaves Semaphore.tryAcquire(long, TimeUnit), the timed form.
      Parameters:
      receiver - the semaphore
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      whether a permit was taken
      Throws:
      InterruptedException - if interrupted while waiting
    • tryAcquire

      public static boolean tryAcquire(Semaphore receiver, int permits, long timeout, TimeUnit unit) throws InterruptedException
      Weaves Semaphore.tryAcquire(int, long, TimeUnit).
      Parameters:
      receiver - the semaphore
      permits - how many permits to take
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      whether they were taken
      Throws:
      InterruptedException - if interrupted while waiting
    • release

      public static void release(Semaphore receiver, int permits)
      Weaves Semaphore.release(int).
      Parameters:
      receiver - the semaphore
      permits - how many permits to return
    • countDown

      public static void countDown(CountDownLatch receiver)
      Weaves CountDownLatch.countDown().

      The latch is observed before it is counted down, which is what lets LatchMisuseDetector recover the count it started from. Observing afterwards would read a count this very call has already decremented.

      Parameters:
      receiver - the latch
    • await

      public static void await(CountDownLatch receiver) throws InterruptedException
      Weaves CountDownLatch.await().
      Parameters:
      receiver - the latch
      Throws:
      InterruptedException - if interrupted while waiting
    • await

      public static boolean await(CountDownLatch receiver, long timeout, TimeUnit unit) throws InterruptedException
      Weaves CountDownLatch.await(long, TimeUnit).

      The timeout branch is the finding: a latch that timed out was not counted down as often as somebody expected, and the boolean saying so is routinely discarded.

      Parameters:
      receiver - the latch
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      whether the latch reached zero before the timeout
      Throws:
      InterruptedException - if interrupted while waiting
    • await

      public static int await(CyclicBarrier receiver) throws InterruptedException, BrokenBarrierException
      Weaves CyclicBarrier.await() (#1246).

      The memory model orders every action a party takes before await before every action any party takes after a normal return from the same generation. The edge is keyed by the barrier's own generation object, read under the barrier's own lock, and the arrival is made inside the same hold: await takes that lock reentrantly, so no other party can trip the barrier between the read and the arrival, and every release into a generation comes from a party that arrived in it. A party already arriving for the next generation therefore cannot publish into the one a slower party is just returning from. The party that trips the barrier runs the barrier action inside its await, and the memory model orders every party's actions before await before the action, and the action before every return (#1267). So the tripping party, seen under the lock as the last to arrive, acquires the generation before its await, and once that returns 0 it releases again before giving up the lock, which no other party can return without. A broken barrier, a timeout, an interrupt or a reset returns abnormally, and acquires nothing; the release is withdrawn. Where the fields cannot be read the call is made unchanged and orders nothing.

      Parameters:
      receiver - the barrier
      Returns:
      the arrival index await returned
      Throws:
      InterruptedException - if interrupted while waiting
      BrokenBarrierException - if the barrier broke
    • await

      public static int await(CyclicBarrier receiver, long timeout, TimeUnit unit) throws InterruptedException, BrokenBarrierException, TimeoutException
      Weaves CyclicBarrier.await(long, TimeUnit), the same edge as await(CyclicBarrier).
      Parameters:
      receiver - the barrier
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      the arrival index await returned
      Throws:
      InterruptedException - if interrupted while waiting
      BrokenBarrierException - if the barrier broke
      TimeoutException - if the timeout elapsed, which breaks the barrier
    • arriveAndAwaitAdvance

      public static int arriveAndAwaitAdvance(Phaser receiver)
      Weaves Phaser.arriveAndAwaitAdvance() (#1265).

      The Phaser javadoc orders every arrival in a phase before every return from waiting for that phase to advance. This party releases into the phase it is in before it arrives, and acquires that phase once the call returns the next one. The phase is read before the call, which is exact for a registered party: the phase cannot advance without its arrival. Where the returned phase says otherwise, an arrival the phaser did not need, the release is withdrawn. A terminated phaser waits for nobody and orders nothing.

      A tiered phaser is keyed by its root: children advance when the root does, with the root's phase numbers, so arrivals on two children of one root order each other.

      Parameters:
      receiver - the phaser
      Returns:
      the phase the call returned: the next phase, or a negative one once terminated
    • arrive

      public static int arrive(Phaser receiver)
      Weaves Phaser.arrive(): a release into the phase it arrives in, as in arriveAndAwaitAdvance(java.util.concurrent.Phaser), with nothing to acquire, since it does not wait (#1265).
      Parameters:
      receiver - the phaser
      Returns:
      the arrival phase, or a negative phase once terminated
    • arriveAndDeregister

      public static int arriveAndDeregister(Phaser receiver)
      Weaves Phaser.arriveAndDeregister(): the same release as arrive(java.util.concurrent.Phaser); the party's last arrival still counts toward the phase it arrives in (#1265).
      Parameters:
      receiver - the phaser
      Returns:
      the arrival phase, or a negative phase once terminated
    • awaitAdvance

      public static int awaitAdvance(Phaser receiver, int phase)
      Weaves Phaser.awaitAdvance(int) (#1265): once the phaser is past phase, every arrival in it happened, so the caller acquires it. A return of phase itself cannot happen for a live phaser, and a negative one means it terminated; neither orders anything. A phase the phaser has not reached yet returns at once and has no token.
      Parameters:
      receiver - the phaser
      phase - the phase to wait out
      Returns:
      the phase the call returned
    • awaitAdvanceInterruptibly

      public static int awaitAdvanceInterruptibly(Phaser receiver, int phase) throws InterruptedException
      Weaves Phaser.awaitAdvanceInterruptibly(int), the same edge as awaitAdvance(Phaser, int) on a normal return.
      Parameters:
      receiver - the phaser
      phase - the phase to wait out
      Returns:
      the phase the call returned
      Throws:
      InterruptedException - if interrupted while waiting
    • awaitAdvanceInterruptibly

      public static int awaitAdvanceInterruptibly(Phaser receiver, int phase, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException
      Weaves Phaser.awaitAdvanceInterruptibly(int, long, TimeUnit), the same edge as awaitAdvance(Phaser, int) on a normal return.
      Parameters:
      receiver - the phaser
      phase - the phase to wait out
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      the phase the call returned
      Throws:
      InterruptedException - if interrupted while waiting
      TimeoutException - if the timeout elapsed first
    • offer

      public static boolean offer(BlockingQueue<Object> receiver, Object element)
      Weaves BlockingQueue.offer(Object).

      The discarded boolean is the bug: an offer that returned false dropped the element, and the caller usually never looks.

      Parameters:
      receiver - the queue
      element - the element to add
      Returns:
      whether the element was added
    • offer

      public static boolean offer(BlockingQueue<Object> receiver, Object element, long timeout, TimeUnit unit) throws InterruptedException
      Weaves BlockingQueue.offer(Object, long, TimeUnit), the timed form.

      The timed overloads are the ones production code reaches for - an untimed offer that returns immediately and an untimed poll that returns null are the shapes people avoid - and neither was woven (#434). The discarded boolean is the same bug either way.

      Parameters:
      receiver - the queue
      element - the element to add
      timeout - how long to wait for space
      unit - the unit of timeout
      Returns:
      whether the element was added
      Throws:
      InterruptedException - if interrupted while waiting
    • offerResultDiscarded

      public static void offerResultDiscarded(boolean added)
      Weaves the POP that follows a BlockingQueue.offer whose result the caller never read.

      Not an operation of its own. The offer already happened and was recorded by offer(BlockingQueue, Object) or its timed form, on this thread, as the instruction before this one: the weaver substitutes this call for the POP and for nothing else, so adjacency is guaranteed by construction rather than assumed. What this adds is the one fact the return value cannot carry - nobody looked. A false that was branched on is backpressure working; a false that was popped is an element dropped on the floor, and the detector counts only the second as a finding (#454).

      Parameters:
      added - what the offer returned, which is the value the caller discarded
      Since:
      1.11.1
    • poll

      public static Object poll(BlockingQueue<Object> receiver, long timeout, TimeUnit unit) throws InterruptedException
      Weaves BlockingQueue.poll(long, TimeUnit), the timed form.
      Parameters:
      receiver - the queue
      timeout - how long to wait for an element
      unit - the unit of timeout
      Returns:
      the head of the queue, or null on timeout
      Throws:
      InterruptedException - if interrupted while waiting
    • poll

      public static Object poll(BlockingQueue<Object> receiver)
      Weaves BlockingQueue.poll().
      Parameters:
      receiver - the queue
      Returns:
      the head of the queue, or null when it was empty
    • take

      public static Object take(BlockingQueue<Object> receiver) throws InterruptedException
      Weaves BlockingQueue.take().

      A take hands the head to this thread exactly as poll does, so it is reported the same way, with the queue as container (#664). Unwoven, it left the offer that put the element there on record, and an element put back by another thread through a call nothing observes then named the first offerer as owner of its next generation.

      Parameters:
      receiver - the queue
      Returns:
      the head of the queue
      Throws:
      InterruptedException - if interrupted while waiting
      Since:
      1.12.2
    • drainTo

      public static int drainTo(BlockingQueue<Object> receiver, Collection<Object> target)
      Weaves BlockingQueue.drainTo(Collection).

      The elements move into target without being named one by one, so the drain is reported as a whole: every offer into this queue recorded before it is stale (#664). The happens-before model is told per element where the target is a list (#1295).

      Parameters:
      receiver - the queue
      target - the collection the elements move to
      Returns:
      how many elements moved
      Since:
      1.12.2
    • drainTo

      public static int drainTo(BlockingQueue<Object> receiver, Collection<Object> target, int maxElements)
      Weaves BlockingQueue.drainTo(Collection, int), reported like drainTo(BlockingQueue, Collection).
      Parameters:
      receiver - the queue
      target - the collection the elements move to
      maxElements - the most elements to move
      Returns:
      how many elements moved
      Since:
      1.12.2
    • put

      public static void put(BlockingQueue<Object> receiver, Object element) throws InterruptedException
      Weaves BlockingQueue.put(Object).
      Parameters:
      receiver - the queue
      element - the element to add
      Throws:
      InterruptedException - if interrupted while waiting for space
    • complete

      public static boolean complete(CompletableFuture<Object> receiver, @Nullable Object value)
      Weaves CompletableFuture.complete(Object): the completing thread's accesses are published to whoever observes the completion (#741). A future that was already complete refuses the value, and the release is withdrawn.
      Parameters:
      receiver - the future
      value - the value to complete it with
      Returns:
      whether this call completed the future
      Since:
      1.12.3
    • completeExceptionally

      public static boolean completeExceptionally(CompletableFuture<Object> receiver, Throwable failure)
      Weaves CompletableFuture.completeExceptionally(Throwable), a completion like complete(java.util.concurrent.CompletableFuture<java.lang.Object>, java.lang.Object): a join that throws with the failure observed it too (#741).
      Parameters:
      receiver - the future
      failure - the exception to complete it with
      Returns:
      whether this call completed the future
      Since:
      1.12.3
    • obtrudeValue

      public static void obtrudeValue(CompletableFuture<Object> receiver, @Nullable Object value)
      Weaves CompletableFuture.obtrudeValue(Object), which completes the future whatever it held (#741).
      Parameters:
      receiver - the future
      value - the value it now holds
      Since:
      1.12.3
    • obtrudeException

      public static void obtrudeException(CompletableFuture<Object> receiver, Throwable failure)
      Weaves CompletableFuture.obtrudeException(Throwable), which completes the future exceptionally whatever it held (#741).
      Parameters:
      receiver - the future
      failure - the exception it now holds
      Since:
      1.12.3
    • join

      public static @Nullable Object join(CompletableFuture<Object> receiver)
      Weaves CompletableFuture.join(): a join that returned, or threw the exception the future completed with, observed the completion and is ordered after it (#741).
      Parameters:
      receiver - the future
      Returns:
      its value
      Since:
      1.12.3
    • get

      public static @Nullable Object get(Future<Object> receiver) throws InterruptedException, ExecutionException
      Weaves Future.get(): a get that returned, or threw the task's exception, observed the completion and is ordered after it (#741). Matches a CompletableFuture.get as well, which is the same method.
      Parameters:
      receiver - the future
      Returns:
      its value
      Throws:
      InterruptedException - if interrupted while waiting
      ExecutionException - if the task completed exceptionally
      Since:
      1.12.3
    • get

      public static @Nullable Object get(Future<Object> receiver, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
      Weaves Future.get(long, TimeUnit), as get(Future); a get that timed out observed nothing.
      Parameters:
      receiver - the future
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      its value
      Throws:
      InterruptedException - if interrupted while waiting
      ExecutionException - if the task completed exceptionally
      TimeoutException - if the wait timed out
      Since:
      1.12.3
    • processBuilderStart

      public static Process processBuilderStart(ProcessBuilder receiver) throws IOException
      Weaves ProcessBuilder.start(): the child is started, then recorded on PROCESS_STREAM_STARVATION with its builder, which alone tells a stderr merged into stdout from a pipe on Linux.
      Parameters:
      receiver - the builder
      Returns:
      the started child
      Throws:
      IOException - if the child cannot be started
      Since:
      1.13.2
    • processBuilderStartPipeline

      public static List<Process> processBuilderStartPipeline(List<ProcessBuilder> builders) throws IOException
      Weaves ProcessBuilder.startPipeline(List), as processBuilderStart(java.lang.ProcessBuilder) for each builder and the child it started.
      Parameters:
      builders - the builders, in pipeline order
      Returns:
      the started children, in the same order
      Throws:
      IOException - if a child cannot be started
      Since:
      1.13.2
    • processWaitFor

      public static int processWaitFor(Process receiver) throws InterruptedException
      Weaves Process.waitFor(): the wait is recorded on PROCESS_STREAM_STARVATION with the output pipes no thread had taken yet, then made.
      Parameters:
      receiver - the child process
      Returns:
      its exit value
      Throws:
      InterruptedException - if interrupted while waiting
      Since:
      1.13.2
    • processWaitFor

      public static boolean processWaitFor(Process receiver, long timeout, TimeUnit unit) throws InterruptedException
      Weaves Process.waitFor(long, TimeUnit), as processWaitFor(Process): a wait with a timeout still waits on a child that cannot finish.
      Parameters:
      receiver - the child process
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      whether the child exited in time
      Throws:
      InterruptedException - if interrupted while waiting
      Since:
      1.13.2
    • processWaitFor

      public static boolean processWaitFor(Process receiver, Duration duration) throws InterruptedException
      Weaves Process.waitFor(Duration), as processWaitFor(Process). The method exists from JDK 25 and the library compiles for 21, so it is called through a handle resolved once; on an older JDK no call site can carry this descriptor, and the hook is never reached.
      Parameters:
      receiver - the child process
      duration - how long to wait
      Returns:
      whether the child exited in time
      Throws:
      InterruptedException - if interrupted while waiting
      Since:
      1.13.2
    • processInputStream

      public static InputStream processInputStream(Process receiver)
      Weaves Process.getInputStream(): with PROCESS_STREAM_STARVATION on, the caller gets the child's stdout pipe in a stream that notes who reads it and whether it reached its end, so a pipe taken before a wait but read only after it is told from one read first (#998). Otherwise the pipe itself.
      Parameters:
      receiver - the child process
      Returns:
      the stream
      Since:
      1.13.2
    • processErrorStream

      public static InputStream processErrorStream(Process receiver)
      Weaves Process.getErrorStream(), as processInputStream(java.lang.Process) for stderr.
      Parameters:
      receiver - the child process
      Returns:
      the stream
      Since:
      1.13.2
    • processInputReader

      public static BufferedReader processInputReader(Process receiver)
      Weaves Process.inputReader(), as processInputStream(java.lang.Process).
      Parameters:
      receiver - the child process
      Returns:
      the reader
      Since:
      1.13.2
    • processInputReader

      public static BufferedReader processInputReader(Process receiver, Charset charset)
      Weaves Process.inputReader(Charset), as processInputStream(java.lang.Process).
      Parameters:
      receiver - the child process
      charset - the charset to decode with
      Returns:
      the reader
      Since:
      1.13.2
    • processErrorReader

      public static BufferedReader processErrorReader(Process receiver)
      Weaves Process.errorReader(), as processErrorStream(java.lang.Process).
      Parameters:
      receiver - the child process
      Returns:
      the reader
      Since:
      1.13.2
    • processErrorReader

      public static BufferedReader processErrorReader(Process receiver, Charset charset)
      Weaves Process.errorReader(Charset), as processErrorStream(java.lang.Process).
      Parameters:
      receiver - the child process
      charset - the charset to decode with
      Returns:
      the reader
      Since:
      1.13.2
    • pipedWrite

      public static void pipedWrite(PipedOutputStream receiver, int b) throws IOException
      Weaves PipedOutputStream.write(int): the write is recorded against the pipe's reading end, so one thread on both ends of a pair is reported (#994).
      Parameters:
      receiver - the writing end
      b - the byte
      Throws:
      IOException - as the write does
      Since:
      1.13.2
    • pipedWrite

      public static void pipedWrite(PipedOutputStream receiver, byte[] b, int off, int len) throws IOException
      Weaves PipedOutputStream.write(byte[], int, int), as pipedWrite(java.io.PipedOutputStream, int).
      Parameters:
      receiver - the writing end
      b - the bytes
      off - the first byte to write
      len - how many to write
      Throws:
      IOException - as the write does
      Since:
      1.13.2
    • pipedWrite

      public static void pipedWrite(PipedOutputStream receiver, byte[] b) throws IOException
      Weaves PipedOutputStream.write(byte[]), as pipedWrite(java.io.PipedOutputStream, int).
      Parameters:
      receiver - the writing end
      b - the bytes
      Throws:
      IOException - as the write does
      Since:
      1.13.2
    • pipedRead

      public static int pipedRead(PipedInputStream receiver) throws IOException
      Weaves PipedInputStream.read(): the read is recorded against the pipe (#994).
      Parameters:
      receiver - the reading end
      Returns:
      what the read returns
      Throws:
      IOException - as the read does
      Since:
      1.13.2
    • pipedRead

      public static int pipedRead(PipedInputStream receiver, byte[] b, int off, int len) throws IOException
      Weaves PipedInputStream.read(byte[], int, int), as pipedRead(java.io.PipedInputStream).
      Parameters:
      receiver - the reading end
      b - where to read into
      off - the first index to fill
      len - how many bytes at most
      Returns:
      what the read returns
      Throws:
      IOException - as the read does
      Since:
      1.13.2
    • pipedRead

      public static int pipedRead(PipedInputStream receiver, byte[] b) throws IOException
      Weaves PipedInputStream.read(byte[]), as pipedRead(java.io.PipedInputStream).
      Parameters:
      receiver - the reading end
      b - where to read into
      Returns:
      what the read returns
      Throws:
      IOException - as the read does
      Since:
      1.13.2
    • thenApply

      public static CompletableFuture<Object> thenApply(CompletableFuture<Object> receiver, Function<Object,Object> function)
      Weaves CompletableFuture.thenApply(Function): the function runs wrapped, after this thread's clock and the completion it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenApplyAsync

      public static CompletableFuture<Object> thenApplyAsync(CompletableFuture<Object> receiver, Function<Object,Object> function)
      Weaves CompletableFuture.thenApplyAsync(Function), as thenApply(CompletableFuture, Function).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenApplyAsync

      public static CompletableFuture<Object> thenApplyAsync(CompletableFuture<Object> receiver, Function<Object,Object> function, Executor executor)
      Weaves CompletableFuture.thenApplyAsync(Function, Executor), as thenApply(CompletableFuture, Function).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAccept

      public static CompletableFuture<Void> thenAccept(CompletableFuture<Object> receiver, Consumer<Object> action)
      Weaves CompletableFuture.thenAccept(Consumer): the function runs wrapped, after this thread's clock and the completion it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptAsync

      public static CompletableFuture<Void> thenAcceptAsync(CompletableFuture<Object> receiver, Consumer<Object> action)
      Weaves CompletableFuture.thenAcceptAsync(Consumer), as thenAccept(CompletableFuture, Consumer).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptAsync

      public static CompletableFuture<Void> thenAcceptAsync(CompletableFuture<Object> receiver, Consumer<Object> action, Executor executor)
      Weaves CompletableFuture.thenAcceptAsync(Consumer, Executor), as thenAccept(CompletableFuture, Consumer).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenRun

      public static CompletableFuture<Void> thenRun(CompletableFuture<Object> receiver, Runnable action)
      Weaves CompletableFuture.thenRun(Runnable): the function runs wrapped, after this thread's clock and the completion it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenRunAsync

      public static CompletableFuture<Void> thenRunAsync(CompletableFuture<Object> receiver, Runnable action)
      Weaves CompletableFuture.thenRunAsync(Runnable), as thenRun(CompletableFuture, Runnable).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenRunAsync

      public static CompletableFuture<Void> thenRunAsync(CompletableFuture<Object> receiver, Runnable action, Executor executor)
      Weaves CompletableFuture.thenRunAsync(Runnable, Executor), as thenRun(CompletableFuture, Runnable).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenCombine

      public static CompletableFuture<Object> thenCombine(CompletableFuture<Object> receiver, CompletionStage<Object> other, BiFunction<Object,Object,Object> function)
      Weaves CompletableFuture.thenCombine(CompletionStage, BiFunction): the function runs wrapped, after this thread's clock and the completions it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenCombineAsync

      public static CompletableFuture<Object> thenCombineAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, BiFunction<Object,Object,Object> function)
      Weaves CompletableFuture.thenCombineAsync(CompletionStage, BiFunction), as thenCombine(CompletableFuture, CompletionStage, BiFunction).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenCombineAsync

      public static CompletableFuture<Object> thenCombineAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, BiFunction<Object,Object,Object> function, Executor executor)
      Weaves CompletableFuture.thenCombineAsync(CompletionStage, BiFunction, Executor), as thenCombine(CompletableFuture, CompletionStage, BiFunction).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      function - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptBoth

      public static CompletableFuture<Void> thenAcceptBoth(CompletableFuture<Object> receiver, CompletionStage<Object> other, BiConsumer<Object,Object> action)
      Weaves CompletableFuture.thenAcceptBoth(CompletionStage, BiConsumer): the function runs wrapped, after this thread's clock and the completions it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptBothAsync

      public static CompletableFuture<Void> thenAcceptBothAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, BiConsumer<Object,Object> action)
      Weaves CompletableFuture.thenAcceptBothAsync(CompletionStage, BiConsumer), as thenAcceptBoth(CompletableFuture, CompletionStage, BiConsumer).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptBothAsync

      public static CompletableFuture<Void> thenAcceptBothAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, BiConsumer<Object,Object> action, Executor executor)
      Weaves CompletableFuture.thenAcceptBothAsync(CompletionStage, BiConsumer, Executor), as thenAcceptBoth(CompletableFuture, CompletionStage, BiConsumer).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterBoth

      public static CompletableFuture<Void> runAfterBoth(CompletableFuture<Object> receiver, CompletionStage<Object> other, Runnable action)
      Weaves CompletableFuture.runAfterBoth(CompletionStage, Runnable): the function runs wrapped, after this thread's clock and the completions it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterBothAsync

      public static CompletableFuture<Void> runAfterBothAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, Runnable action)
      Weaves CompletableFuture.runAfterBothAsync(CompletionStage, Runnable), as runAfterBoth(CompletableFuture, CompletionStage, Runnable).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterBothAsync

      public static CompletableFuture<Void> runAfterBothAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, Runnable action, Executor executor)
      Weaves CompletableFuture.runAfterBothAsync(CompletionStage, Runnable, Executor), as runAfterBoth(CompletableFuture, CompletionStage, Runnable).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • applyToEither

      public static CompletableFuture<Object> applyToEither(CompletableFuture<Object> receiver, CompletionStage<Object> other, Function<Object,Object> function)
      Weaves CompletableFuture.applyToEither(CompletionStage, Function): the function runs wrapped, after this thread's clock only, since which stage it followed is not known, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • applyToEitherAsync

      public static CompletableFuture<Object> applyToEitherAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, Function<Object,Object> function)
      Weaves CompletableFuture.applyToEitherAsync(CompletionStage, Function), as applyToEither(CompletableFuture, CompletionStage, Function).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • applyToEitherAsync

      public static CompletableFuture<Object> applyToEitherAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, Function<Object,Object> function, Executor executor)
      Weaves CompletableFuture.applyToEitherAsync(CompletionStage, Function, Executor), as applyToEither(CompletableFuture, CompletionStage, Function).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      function - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • acceptEither

      public static CompletableFuture<Void> acceptEither(CompletableFuture<Object> receiver, CompletionStage<Object> other, Consumer<Object> action)
      Weaves CompletableFuture.acceptEither(CompletionStage, Consumer): the function runs wrapped, after this thread's clock only, since which stage it followed is not known, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • acceptEitherAsync

      public static CompletableFuture<Void> acceptEitherAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, Consumer<Object> action)
      Weaves CompletableFuture.acceptEitherAsync(CompletionStage, Consumer), as acceptEither(CompletableFuture, CompletionStage, Consumer).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • acceptEitherAsync

      public static CompletableFuture<Void> acceptEitherAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, Consumer<Object> action, Executor executor)
      Weaves CompletableFuture.acceptEitherAsync(CompletionStage, Consumer, Executor), as acceptEither(CompletableFuture, CompletionStage, Consumer).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterEither

      public static CompletableFuture<Void> runAfterEither(CompletableFuture<Object> receiver, CompletionStage<Object> other, Runnable action)
      Weaves CompletableFuture.runAfterEither(CompletionStage, Runnable): the function runs wrapped, after this thread's clock only, since which stage it followed is not known, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterEitherAsync

      public static CompletableFuture<Void> runAfterEitherAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, Runnable action)
      Weaves CompletableFuture.runAfterEitherAsync(CompletionStage, Runnable), as runAfterEither(CompletableFuture, CompletionStage, Runnable).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterEitherAsync

      public static CompletableFuture<Void> runAfterEitherAsync(CompletableFuture<Object> receiver, CompletionStage<Object> other, Runnable action, Executor executor)
      Weaves CompletableFuture.runAfterEitherAsync(CompletionStage, Runnable, Executor), as runAfterEither(CompletableFuture, CompletionStage, Runnable).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenCompose

      public static CompletableFuture<Object> thenCompose(CompletableFuture<Object> receiver, Function<Object,Object> function)
      Weaves CompletableFuture.thenCompose(Function): the function runs wrapped, after this thread's clock and the completion it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenComposeAsync

      public static CompletableFuture<Object> thenComposeAsync(CompletableFuture<Object> receiver, Function<Object,Object> function)
      Weaves CompletableFuture.thenComposeAsync(Function), as thenCompose(CompletableFuture, Function).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenComposeAsync

      public static CompletableFuture<Object> thenComposeAsync(CompletableFuture<Object> receiver, Function<Object,Object> function, Executor executor)
      Weaves CompletableFuture.thenComposeAsync(Function, Executor), as thenCompose(CompletableFuture, Function).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • whenComplete

      public static CompletableFuture<Object> whenComplete(CompletableFuture<Object> receiver, BiConsumer<Object,Object> action)
      Weaves CompletableFuture.whenComplete(BiConsumer): the function runs wrapped, after this thread's clock and the completion it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • whenCompleteAsync

      public static CompletableFuture<Object> whenCompleteAsync(CompletableFuture<Object> receiver, BiConsumer<Object,Object> action)
      Weaves CompletableFuture.whenCompleteAsync(BiConsumer), as whenComplete(CompletableFuture, BiConsumer).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • whenCompleteAsync

      public static CompletableFuture<Object> whenCompleteAsync(CompletableFuture<Object> receiver, BiConsumer<Object,Object> action, Executor executor)
      Weaves CompletableFuture.whenCompleteAsync(BiConsumer, Executor), as whenComplete(CompletableFuture, BiConsumer).
      Parameters:
      receiver - the stage the function follows
      action - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • handle

      public static CompletableFuture<Object> handle(CompletableFuture<Object> receiver, BiFunction<Object,Object,Object> function)
      Weaves CompletableFuture.handle(BiFunction): the function runs wrapped, after this thread's clock and the completion it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • handleAsync

      public static CompletableFuture<Object> handleAsync(CompletableFuture<Object> receiver, BiFunction<Object,Object,Object> function)
      Weaves CompletableFuture.handleAsync(BiFunction), as handle(CompletableFuture, BiFunction).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • handleAsync

      public static CompletableFuture<Object> handleAsync(CompletableFuture<Object> receiver, BiFunction<Object,Object,Object> function, Executor executor)
      Weaves CompletableFuture.handleAsync(BiFunction, Executor), as handle(CompletableFuture, BiFunction).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionally

      public static CompletableFuture<Object> exceptionally(CompletableFuture<Object> receiver, Function<Object,Object> function)
      Weaves CompletableFuture.exceptionally(Function): the function runs wrapped, after this thread's clock and the completion it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyAsync

      public static CompletableFuture<Object> exceptionallyAsync(CompletableFuture<Object> receiver, Function<Object,Object> function)
      Weaves CompletableFuture.exceptionallyAsync(Function), as exceptionally(CompletableFuture, Function).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyAsync

      public static CompletableFuture<Object> exceptionallyAsync(CompletableFuture<Object> receiver, Function<Object,Object> function, Executor executor)
      Weaves CompletableFuture.exceptionallyAsync(Function, Executor), as exceptionally(CompletableFuture, Function).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyCompose

      public static CompletableFuture<Object> exceptionallyCompose(CompletableFuture<Object> receiver, Function<Object,Object> function)
      Weaves CompletableFuture.exceptionallyCompose(Function): the function runs wrapped, after this thread's clock and the completion it follows, and a join of the returned stage on this thread is ordered after it (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyComposeAsync

      public static CompletableFuture<Object> exceptionallyComposeAsync(CompletableFuture<Object> receiver, Function<Object,Object> function)
      Weaves CompletableFuture.exceptionallyComposeAsync(Function), as exceptionallyCompose(CompletableFuture, Function).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyComposeAsync

      public static CompletableFuture<Object> exceptionallyComposeAsync(CompletableFuture<Object> receiver, Function<Object,Object> function, Executor executor)
      Weaves CompletableFuture.exceptionallyComposeAsync(Function, Executor), as exceptionallyCompose(CompletableFuture, Function).
      Parameters:
      receiver - the stage the function follows
      function - what runs next; the thread running it receives this thread's clock first
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenApply

      public static CompletionStage<Object> thenApply(CompletionStage<Object> receiver, Function<Object,Object> function)
      Weaves CompletionStage.thenApply(Function): on a CompletableFuture, as thenApply(CompletableFuture, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenApplyAsync

      public static CompletionStage<Object> thenApplyAsync(CompletionStage<Object> receiver, Function<Object,Object> function)
      Weaves CompletionStage.thenApplyAsync(Function): on a CompletableFuture, as thenApplyAsync(CompletableFuture, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenApplyAsync

      public static CompletionStage<Object> thenApplyAsync(CompletionStage<Object> receiver, Function<Object,Object> function, Executor executor)
      Weaves CompletionStage.thenApplyAsync(Function, Executor): on a CompletableFuture, as thenApplyAsync(CompletableFuture, Function, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAccept

      public static CompletionStage<Void> thenAccept(CompletionStage<Object> receiver, Consumer<Object> action)
      Weaves CompletionStage.thenAccept(Consumer): on a CompletableFuture, as thenAccept(CompletableFuture, Consumer); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptAsync

      public static CompletionStage<Void> thenAcceptAsync(CompletionStage<Object> receiver, Consumer<Object> action)
      Weaves CompletionStage.thenAcceptAsync(Consumer): on a CompletableFuture, as thenAcceptAsync(CompletableFuture, Consumer); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptAsync

      public static CompletionStage<Void> thenAcceptAsync(CompletionStage<Object> receiver, Consumer<Object> action, Executor executor)
      Weaves CompletionStage.thenAcceptAsync(Consumer, Executor): on a CompletableFuture, as thenAcceptAsync(CompletableFuture, Consumer, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenRun

      public static CompletionStage<Void> thenRun(CompletionStage<Object> receiver, Runnable action)
      Weaves CompletionStage.thenRun(Runnable): on a CompletableFuture, as thenRun(CompletableFuture, Runnable); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenRunAsync

      public static CompletionStage<Void> thenRunAsync(CompletionStage<Object> receiver, Runnable action)
      Weaves CompletionStage.thenRunAsync(Runnable): on a CompletableFuture, as thenRunAsync(CompletableFuture, Runnable); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenRunAsync

      public static CompletionStage<Void> thenRunAsync(CompletionStage<Object> receiver, Runnable action, Executor executor)
      Weaves CompletionStage.thenRunAsync(Runnable, Executor): on a CompletableFuture, as thenRunAsync(CompletableFuture, Runnable, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenCombine

      public static CompletionStage<Object> thenCombine(CompletionStage<Object> receiver, CompletionStage<Object> other, BiFunction<Object,Object,Object> function)
      Weaves CompletionStage.thenCombine(CompletionStage, BiFunction): on a CompletableFuture, as thenCombine(CompletableFuture, CompletionStage, BiFunction); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenCombineAsync

      public static CompletionStage<Object> thenCombineAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, BiFunction<Object,Object,Object> function)
      Weaves CompletionStage.thenCombineAsync(CompletionStage, BiFunction): on a CompletableFuture, as thenCombineAsync(CompletableFuture, CompletionStage, BiFunction); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenCombineAsync

      public static CompletionStage<Object> thenCombineAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, BiFunction<Object,Object,Object> function, Executor executor)
      Weaves CompletionStage.thenCombineAsync(CompletionStage, BiFunction, Executor): on a CompletableFuture, as thenCombineAsync(CompletableFuture, CompletionStage, BiFunction, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      function - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptBoth

      public static CompletionStage<Void> thenAcceptBoth(CompletionStage<Object> receiver, CompletionStage<Object> other, BiConsumer<Object,Object> action)
      Weaves CompletionStage.thenAcceptBoth(CompletionStage, BiConsumer): on a CompletableFuture, as thenAcceptBoth(CompletableFuture, CompletionStage, BiConsumer); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptBothAsync

      public static CompletionStage<Void> thenAcceptBothAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, BiConsumer<Object,Object> action)
      Weaves CompletionStage.thenAcceptBothAsync(CompletionStage, BiConsumer): on a CompletableFuture, as thenAcceptBothAsync(CompletableFuture, CompletionStage, BiConsumer); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenAcceptBothAsync

      public static CompletionStage<Void> thenAcceptBothAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, BiConsumer<Object,Object> action, Executor executor)
      Weaves CompletionStage.thenAcceptBothAsync(CompletionStage, BiConsumer, Executor): on a CompletableFuture, as thenAcceptBothAsync(CompletableFuture, CompletionStage, BiConsumer, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterBoth

      public static CompletionStage<Void> runAfterBoth(CompletionStage<Object> receiver, CompletionStage<Object> other, Runnable action)
      Weaves CompletionStage.runAfterBoth(CompletionStage, Runnable): on a CompletableFuture, as runAfterBoth(CompletableFuture, CompletionStage, Runnable); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterBothAsync

      public static CompletionStage<Void> runAfterBothAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, Runnable action)
      Weaves CompletionStage.runAfterBothAsync(CompletionStage, Runnable): on a CompletableFuture, as runAfterBothAsync(CompletableFuture, CompletionStage, Runnable); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterBothAsync

      public static CompletionStage<Void> runAfterBothAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, Runnable action, Executor executor)
      Weaves CompletionStage.runAfterBothAsync(CompletionStage, Runnable, Executor): on a CompletableFuture, as runAfterBothAsync(CompletableFuture, CompletionStage, Runnable, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage, which must also complete before the function runs
      action - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • applyToEither

      public static CompletionStage<Object> applyToEither(CompletionStage<Object> receiver, CompletionStage<Object> other, Function<Object,Object> function)
      Weaves CompletionStage.applyToEither(CompletionStage, Function): on a CompletableFuture, as applyToEither(CompletableFuture, CompletionStage, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • applyToEitherAsync

      public static CompletionStage<Object> applyToEitherAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, Function<Object,Object> function)
      Weaves CompletionStage.applyToEitherAsync(CompletionStage, Function): on a CompletableFuture, as applyToEitherAsync(CompletableFuture, CompletionStage, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • applyToEitherAsync

      public static CompletionStage<Object> applyToEitherAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, Function<Object,Object> function, Executor executor)
      Weaves CompletionStage.applyToEitherAsync(CompletionStage, Function, Executor): on a CompletableFuture, as applyToEitherAsync(CompletableFuture, CompletionStage, Function, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      function - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • acceptEither

      public static CompletionStage<Void> acceptEither(CompletionStage<Object> receiver, CompletionStage<Object> other, Consumer<Object> action)
      Weaves CompletionStage.acceptEither(CompletionStage, Consumer): on a CompletableFuture, as acceptEither(CompletableFuture, CompletionStage, Consumer); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • acceptEitherAsync

      public static CompletionStage<Void> acceptEitherAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, Consumer<Object> action)
      Weaves CompletionStage.acceptEitherAsync(CompletionStage, Consumer): on a CompletableFuture, as acceptEitherAsync(CompletableFuture, CompletionStage, Consumer); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • acceptEitherAsync

      public static CompletionStage<Void> acceptEitherAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, Consumer<Object> action, Executor executor)
      Weaves CompletionStage.acceptEitherAsync(CompletionStage, Consumer, Executor): on a CompletableFuture, as acceptEitherAsync(CompletableFuture, CompletionStage, Consumer, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterEither

      public static CompletionStage<Void> runAfterEither(CompletionStage<Object> receiver, CompletionStage<Object> other, Runnable action)
      Weaves CompletionStage.runAfterEither(CompletionStage, Runnable): on a CompletableFuture, as runAfterEither(CompletableFuture, CompletionStage, Runnable); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterEitherAsync

      public static CompletionStage<Void> runAfterEitherAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, Runnable action)
      Weaves CompletionStage.runAfterEitherAsync(CompletionStage, Runnable): on a CompletableFuture, as runAfterEitherAsync(CompletableFuture, CompletionStage, Runnable); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • runAfterEitherAsync

      public static CompletionStage<Void> runAfterEitherAsync(CompletionStage<Object> receiver, CompletionStage<Object> other, Runnable action, Executor executor)
      Weaves CompletionStage.runAfterEitherAsync(CompletionStage, Runnable, Executor): on a CompletableFuture, as runAfterEitherAsync(CompletableFuture, CompletionStage, Runnable, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      other - the second stage; either one completing runs the function
      action - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenCompose

      public static CompletionStage<Object> thenCompose(CompletionStage<Object> receiver, Function<Object,Object> function)
      Weaves CompletionStage.thenCompose(Function): on a CompletableFuture, as thenCompose(CompletableFuture, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenComposeAsync

      public static CompletionStage<Object> thenComposeAsync(CompletionStage<Object> receiver, Function<Object,Object> function)
      Weaves CompletionStage.thenComposeAsync(Function): on a CompletableFuture, as thenComposeAsync(CompletableFuture, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • thenComposeAsync

      public static CompletionStage<Object> thenComposeAsync(CompletionStage<Object> receiver, Function<Object,Object> function, Executor executor)
      Weaves CompletionStage.thenComposeAsync(Function, Executor): on a CompletableFuture, as thenComposeAsync(CompletableFuture, Function, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • whenComplete

      public static CompletionStage<Object> whenComplete(CompletionStage<Object> receiver, BiConsumer<Object,Object> action)
      Weaves CompletionStage.whenComplete(BiConsumer): on a CompletableFuture, as whenComplete(CompletableFuture, BiConsumer); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • whenCompleteAsync

      public static CompletionStage<Object> whenCompleteAsync(CompletionStage<Object> receiver, BiConsumer<Object,Object> action)
      Weaves CompletionStage.whenCompleteAsync(BiConsumer): on a CompletableFuture, as whenCompleteAsync(CompletableFuture, BiConsumer); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • whenCompleteAsync

      public static CompletionStage<Object> whenCompleteAsync(CompletionStage<Object> receiver, BiConsumer<Object,Object> action, Executor executor)
      Weaves CompletionStage.whenCompleteAsync(BiConsumer, Executor): on a CompletableFuture, as whenCompleteAsync(CompletableFuture, BiConsumer, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      action - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • handle

      public static CompletionStage<Object> handle(CompletionStage<Object> receiver, BiFunction<Object,Object,Object> function)
      Weaves CompletionStage.handle(BiFunction): on a CompletableFuture, as handle(CompletableFuture, BiFunction); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • handleAsync

      public static CompletionStage<Object> handleAsync(CompletionStage<Object> receiver, BiFunction<Object,Object,Object> function)
      Weaves CompletionStage.handleAsync(BiFunction): on a CompletableFuture, as handleAsync(CompletableFuture, BiFunction); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • handleAsync

      public static CompletionStage<Object> handleAsync(CompletionStage<Object> receiver, BiFunction<Object,Object,Object> function, Executor executor)
      Weaves CompletionStage.handleAsync(BiFunction, Executor): on a CompletableFuture, as handleAsync(CompletableFuture, BiFunction, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionally

      public static CompletionStage<Object> exceptionally(CompletionStage<Object> receiver, Function<Object,Object> function)
      Weaves CompletionStage.exceptionally(Function): on a CompletableFuture, as exceptionally(CompletableFuture, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyAsync

      public static CompletionStage<Object> exceptionallyAsync(CompletionStage<Object> receiver, Function<Object,Object> function)
      Weaves CompletionStage.exceptionallyAsync(Function): on a CompletableFuture, as exceptionallyAsync(CompletableFuture, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyAsync

      public static CompletionStage<Object> exceptionallyAsync(CompletionStage<Object> receiver, Function<Object,Object> function, Executor executor)
      Weaves CompletionStage.exceptionallyAsync(Function, Executor): on a CompletableFuture, as exceptionallyAsync(CompletableFuture, Function, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyCompose

      public static CompletionStage<Object> exceptionallyCompose(CompletionStage<Object> receiver, Function<Object,Object> function)
      Weaves CompletionStage.exceptionallyCompose(Function): on a CompletableFuture, as exceptionallyCompose(CompletableFuture, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyComposeAsync

      public static CompletionStage<Object> exceptionallyComposeAsync(CompletionStage<Object> receiver, Function<Object,Object> function)
      Weaves CompletionStage.exceptionallyComposeAsync(Function): on a CompletableFuture, as exceptionallyComposeAsync(CompletableFuture, Function); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • exceptionallyComposeAsync

      public static CompletionStage<Object> exceptionallyComposeAsync(CompletionStage<Object> receiver, Function<Object,Object> function, Executor executor)
      Weaves CompletionStage.exceptionallyComposeAsync(Function, Executor): on a CompletableFuture, as exceptionallyComposeAsync(CompletableFuture, Function, Executor); any other stage gets the caller's function unwrapped, since it may hand it back (#741).
      Parameters:
      receiver - the stage the function follows
      function - what runs next
      executor - the executor the function runs on
      Returns:
      the stage the caller gets
      Since:
      1.12.4
    • supplyAsync

      public static CompletableFuture<Object> supplyAsync(Supplier<Object> supplier)
      Weaves CompletableFuture.supplyAsync(Supplier): the supplier runs as a AgentHandOffHooks.HandedTask, so it starts ordered after this call and a join on this thread is ordered after it finished (#741). The wrapper is internal to the future and never seen.
      Parameters:
      supplier - the value's supplier
      Returns:
      the new future
      Since:
      1.12.3
    • supplyAsync

      public static CompletableFuture<Object> supplyAsync(Supplier<Object> supplier, Executor executor)
      Weaves CompletableFuture.supplyAsync(Supplier, Executor), as supplyAsync(Supplier).
      Parameters:
      supplier - the value's supplier
      executor - the executor to run it on
      Returns:
      the new future
      Since:
      1.12.3
    • allOf

      public static CompletableFuture<Void> allOf(CompletableFuture<?>[] children)
      Weaves CompletableFuture.allOf: a join on what it returns observes every child (see AgentHandOffHooks.HandedAll).
      Parameters:
      children - the futures to wait for
      Returns:
      the future that completes when they all have
      Since:
      1.14.1
    • anyOf

      public static CompletableFuture<Object> anyOf(CompletableFuture<?>[] children)
      Weaves CompletableFuture.anyOf: a join on what it returns observes the children that have completed by then, the one that completed it among them (see AgentHandOffHooks.HandedAll).
      Parameters:
      children - the futures, the first of which to complete completes the result
      Returns:
      the future that completes when one of them has
      Since:
      1.14.3
    • copy

      public static CompletableFuture<Object> copy(CompletableFuture<Object> receiver)
      Weaves CompletableFuture.copy(): the copy completes when the receiver does, so a join on it observes the receiver and the work behind it.
      Parameters:
      receiver - the future copied
      Returns:
      a new future that completes with the receiver's result, remembered on this thread
      Since:
      1.14.3
    • isDone

      public static boolean isDone(Future<?> receiver)
      Weaves Future.isDone(): a true answer read the completion, the read a get would have made, so the caller is ordered after the task as after a returned get. A false answer orders nothing. The work stays remembered for a later get.
      Parameters:
      receiver - the future asked
      Returns:
      whether it has completed
      Since:
      1.14.3
    • runAsync

      public static CompletableFuture<Void> runAsync(Runnable task)
      Weaves CompletableFuture.runAsync(Runnable), as supplyAsync(Supplier).
      Parameters:
      task - the work to run asynchronously, not null; it is wrapped, so its start is ordered after this call
      Returns:
      the new future
      Since:
      1.12.3
    • runAsync

      public static CompletableFuture<Void> runAsync(Runnable task, Executor executor)
      Weaves CompletableFuture.runAsync(Runnable, Executor), as supplyAsync(Supplier).
      Parameters:
      task - the work to run on executor, not null; it is wrapped, so its start is ordered after this call
      executor - the executor to run it on
      Returns:
      the new future
      Since:
      1.12.3
    • asyncResultDiscarded

      public static void asyncResultDiscarded(CompletableFuture<?> future)
      Stands in for the POP after a woven supplyAsync or runAsync whose future the caller never kept. Nothing can join, get or handle that future afterwards, so the detector judges it at analysis by whether its task failed.
      Parameters:
      future - the future the caller discarded
      Since:
      1.13.2
    • runBlockingEntered

      public static void runBlockingEntered()
      Inserted by the agent's RunBlockingWeaver before each call of a Kotlin runBlocking (#1007). It substitutes nothing and takes nothing off the stack: the call that follows it is the original, made unchanged.

      Only BlockingOnNonBlockingThreadDetector hears it, which reports it on a coroutine dispatcher worker or a thread that must not block; the thread is the caller's, so a runBlocking on an ordinary thread, its intended use, reports nothing.

      Since:
      1.14.0
    • kotlinMutexLock

      public static Object kotlinMutexLock(Object mutex, Object owner, Object continuation)
      Weaves kotlinx.coroutines.sync.Mutex.lock(owner, continuation), the call mutex.withLock(owner) { } and mutex.lock(owner) compile to (#1007). Around the lock, KotlinMutexReentrancyDetector learns who holds the mutex and hears a lock that waits for its own coroutine.

      While a run hears it, a call with no owner is made with a fresh owner token instead, so the mutex itself can later say whether this lock still holds it (#1221). kotlinx compares owners by identity and the token matches nothing else, so the lock, an unlock(null) and a tryLock behave exactly as with no owner. The caller's Job is recorded with the owner, and a call that waits while the caller, or a coroutine suspended until the caller's withContext, coroutineScope or withTimeout block completes, holds the mutex is the finding: that wait ends only with an unlock the waiting coroutine itself has to make. The Kotlin types in the real descriptor are not on the library's class path, so the hook takes Objects and calls through a handle bound to the receiver's own kotlinx.

      Parameters:
      mutex - the receiver
      owner - the owner token, or null
      continuation - the calling coroutine's continuation
      Returns:
      what lock returned: Unit, or COROUTINE_SUSPENDED
      Since:
      1.14.2
    • kotlinMutexLockDefault

      public static Object kotlinMutexLockDefault(Object mutex, Object owner, Object continuation, int mask, Object marker)
      Weaves Mutex.lock$default, the call a bare mutex.lock() compiles to, as kotlinMutexLock(java.lang.Object, java.lang.Object, java.lang.Object). The bridge only fills in the defaulted owner, null, and calls lock, so while a run hears the call it is made as lock directly, with the owner token; otherwise the bridge is called unchanged.
      Parameters:
      mutex - the receiver
      owner - the owner token as passed, ignored by kotlinx where mask omits it
      continuation - the calling coroutine's continuation
      mask - which parameters the call site left to their defaults
      marker - always null from a compiled call site
      Returns:
      what lock returned
      Since:
      1.14.2
    • kotlinMutexUnlock

      public static void kotlinMutexUnlock(Object mutex, Object owner)
      Weaves Mutex.unlock(owner), a schedule point; the unlock is made unchanged. Nothing is recorded: whether a lock still holds the mutex is asked of the mutex itself, so an unlock the agent sees and one it does not end a hold alike (#1221).
      Parameters:
      mutex - the receiver
      owner - the owner token, or null
      Since:
      1.14.2
    • kotlinMutexUnlockDefault

      public static void kotlinMutexUnlockDefault(Object mutex, Object owner, int mask, Object marker)
      Parameters:
      mutex - the receiver
      owner - the owner token as passed
      mask - which parameters the call site left to their defaults
      marker - always null from a compiled call site
      Since:
      1.14.2
    • kotlinMutexTryLock

      public static boolean kotlinMutexTryLock(Object mutex, Object owner)
      Weaves Mutex.tryLock(owner) for an agent older than kotlinMutexTryLockIn(java.lang.Object, java.lang.Object, java.lang.Object), which passes no continuation: a schedule point, and the call is made unchanged. The coroutine that took the mutex cannot be named, so nothing is recorded and no lock is judged against it.
      Parameters:
      mutex - the receiver
      owner - the owner token, or null
      Returns:
      whether the mutex was taken
      Since:
      1.14.2
    • kotlinMutexTryLockDefault

      public static boolean kotlinMutexTryLockDefault(Object mutex, Object owner, int mask, Object marker)
      Parameters:
      mutex - the receiver
      owner - the owner token as passed
      mask - which parameters the call site left to their defaults
      marker - always null from a compiled call site
      Returns:
      whether the mutex was taken
      Since:
      1.14.2
    • kotlinMutexTryLockIn

      public static boolean kotlinMutexTryLockIn(Object mutex, Object owner, @Nullable Object continuation)
      Weaves Mutex.tryLock(owner) where the agent could name the calling coroutine (#1220): continuation is the one of the suspend function or lambda the call is made in, which the agent passes because tryLock itself takes none, or null where it found none. While a run hears the call and the continuation names a Job, a call with no owner is made with a fresh owner token, as kotlinMutexLock(java.lang.Object, java.lang.Object, java.lang.Object) does, and a mutex it takes is recorded as held by that Job, so a later lock by the same coroutine that waits for it is reported. A tryLock that finds the mutex taken records nothing and never waits, so it is never itself the finding.
      Parameters:
      mutex - the receiver
      owner - the owner token, or null
      continuation - the enclosing coroutine's continuation, or null
      Returns:
      whether the mutex was taken
      Since:
      1.14.2
    • kotlinMutexTryLockDefaultIn

      public static boolean kotlinMutexTryLockDefaultIn(Object mutex, Object owner, int mask, Object marker, @Nullable Object continuation)
      Weaves Mutex.tryLock$default, the call a bare mutex.tryLock() compiles to, as kotlinMutexTryLockIn(java.lang.Object, java.lang.Object, java.lang.Object). While a run hears the call it is made as tryLock directly, with the owner token; otherwise the bridge is called unchanged.
      Parameters:
      mutex - the receiver
      owner - the owner token as passed, ignored by kotlinx where mask omits it
      mask - which parameters the call site left to their defaults
      marker - always null from a compiled call site
      continuation - the enclosing coroutine's continuation, or null
      Returns:
      whether the mutex was taken
      Since:
      1.14.2
    • kotlinSelectInvokeIn

      public static void kotlinSelectInvokeIn(Object builder, Object clause, Object block, @Nullable Object continuation)
      Weaves SelectBuilder.invoke(clause, block), the registration an inlined select { mutex.onLock { } } compiles to (#1220). continuation is the one of the suspend function or lambda the select is written in, which the agent passes, or null where it found none. While a run hears it and clause is a mutex's onLock, the clause is registered with a fresh owner token, as kotlinMutexLock(java.lang.Object, java.lang.Object, java.lang.Object) makes a lock with no owner, and the token is recorded with the calling coroutine's Job: the mutex then says, through holdsLock, whether the clause was selected and still holds it, and a later lock by the same coroutine that waits for it is reported. kotlinx compares owners by identity, so the select and an unlock(null) behave as with no owner. Every other clause, and every clause while no run hears the call, is registered unchanged. A schedule point, like every substituted call.
      Parameters:
      builder - the receiver, the select's builder
      clause - the clause, a SelectClause2
      block - the clause's block
      continuation - the enclosing coroutine's continuation, or null
      Since:
      1.14.3
    • kotlinSelectInvokeOwnerIn

      public static void kotlinSelectInvokeOwnerIn(Object builder, Object clause, Object owner, Object block, @Nullable Object continuation)
      Weaves SelectBuilder.invoke(clause, owner, block), the registration an inlined select { mutex.onLock(owner) { } } compiles to, as kotlinSelectInvokeIn(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object); an owner the caller passed is kept, and the mutex is asked about that one (#1220).
      Parameters:
      builder - the receiver, the select's builder
      clause - the clause, a SelectClause2
      owner - the clause's parameter: for onLock, the owner token, or null
      block - the clause's block
      continuation - the enclosing coroutine's continuation, or null
      Since:
      1.14.3
    • submit

      public static Future<Object> submit(ExecutorService receiver, Callable<Object> task)
      Weaves ExecutorService.submit(Callable): submitted to a java.util.concurrent executor, the task runs as a AgentHandOffHooks.HandedTask, so it starts ordered after this call and a get on this thread is ordered after it finished (#741).

      Only the JDK's own executors get the wrapper, because only there is it invisible: they wrap every submitted task in a future of their own, and nothing a caller can reach returns the task. A user's executor may override newTaskFor and inspect the task, and a ForkJoinTask is run differently from any other, so both keep the task as it was.

      Parameters:
      receiver - the executor
      task - the work submitted, not null; on a JDK executor it is wrapped, so its run is ordered after this call and a get after its end
      Returns:
      the task's future
      Since:
      1.12.3
    • submit

      public static Future<?> submit(ExecutorService receiver, Runnable task)
      Weaves ExecutorService.submit(Runnable), as submit(ExecutorService, Callable).
      Parameters:
      receiver - the executor
      task - the work submitted, not null; on a JDK executor it is wrapped, as in the Callable form
      Returns:
      the task's future
      Since:
      1.12.3
    • submit

      public static Future<Object> submit(ExecutorService receiver, Runnable task, @Nullable Object result)
      Weaves ExecutorService.submit(Runnable, Object), as submit(ExecutorService, Callable).
      Parameters:
      receiver - the executor
      task - the work submitted, not null; on a JDK executor it is wrapped, as in the Callable form
      result - what the future returns
      Returns:
      the task's future
      Since:
      1.12.3
    • submitResultDiscarded

      public static void submitResultDiscarded(Future<?> future)
      Stands in for the POP after a woven submit whose future the caller never kept. Nothing can inspect that future afterwards, so the detector judges it at analysis by whether its task failed.
      Parameters:
      future - the future the caller discarded
      Since:
      1.13.2
    • schedule

      public static ScheduledFuture<?> schedule(ScheduledExecutorService receiver, Runnable task, long delay, TimeUnit unit)
      Weaves the one-shot ScheduledExecutorService.schedule(Runnable, long, TimeUnit): the task is scheduled unchanged. Like a submit, its future is judged only when the caller pops it, which the weaver turns into scheduleResultDiscarded(java.util.concurrent.ScheduledFuture<?>) (#1281).
      Parameters:
      receiver - the scheduler
      task - the task, scheduled unchanged
      delay - the delay before it runs
      unit - the unit of the delay
      Returns:
      the task's future
      Since:
      1.14.4
    • schedule

      public static ScheduledFuture<Object> schedule(ScheduledExecutorService receiver, Callable<Object> task, long delay, TimeUnit unit)
      Weaves the one-shot ScheduledExecutorService.schedule(Callable, long, TimeUnit), as schedule(ScheduledExecutorService, Runnable, long, TimeUnit) (#1281).
      Parameters:
      receiver - the scheduler
      task - the task, scheduled unchanged
      delay - the delay before it runs
      unit - the unit of the delay
      Returns:
      the task's future
      Since:
      1.14.4
    • scheduleResultDiscarded

      public static void scheduleResultDiscarded(ScheduledFuture<?> future)
      Stands in for the POP after a woven one-shot schedule: the caller discarded the future, so nothing can ever read the task's exception, and the ignored-future detector reports it at analysis if the task threw, as for submitResultDiscarded(java.util.concurrent.Future<?>) (#1281). A task still pending at analysis, such as one delayed past the run's end, draws nothing.
      Parameters:
      future - the future the caller discarded
      Since:
      1.14.4
    • scheduleAtFixedRate

      public static ScheduledFuture<?> scheduleAtFixedRate(ScheduledExecutorService receiver, Runnable task, long initialDelay, long period, TimeUnit unit)
      Weaves ScheduledExecutorService.scheduleAtFixedRate: the task is scheduled as it was, and its future is handed to the ignored-future detector, which reports it at analysis if the task threw, since the executor then cancels every later run and nobody reads a periodic task's future (#1254).
      Parameters:
      receiver - the scheduler
      task - the periodic task, scheduled unchanged
      initialDelay - the delay before the first run
      period - the period between the starts of runs
      unit - the unit of both
      Returns:
      the task's future
      Since:
      1.14.3
    • scheduleWithFixedDelay

      public static ScheduledFuture<?> scheduleWithFixedDelay(ScheduledExecutorService receiver, Runnable task, long initialDelay, long delay, TimeUnit unit)
      Parameters:
      receiver - the scheduler
      task - the periodic task, scheduled unchanged
      initialDelay - the delay before the first run
      delay - the delay between the end of one run and the start of the next
      unit - the unit of both
      Returns:
      the task's future
      Since:
      1.14.3
    • newFixedThreadPool

      public static ExecutorService newFixedThreadPool(int threads)
      Weaves Executors.newFixedThreadPool(int): the pool is declared as the run's own.
      Parameters:
      threads - the number of threads
      Returns:
      the new pool
      Since:
      1.13.2
    • newFixedThreadPool

      public static ExecutorService newFixedThreadPool(int threads, ThreadFactory factory)
      Weaves Executors.newFixedThreadPool(int, ThreadFactory), as newFixedThreadPool(int).
      Parameters:
      threads - the number of threads
      factory - the thread factory
      Returns:
      the new pool
      Since:
      1.13.2
    • newCachedThreadPool

      public static ExecutorService newCachedThreadPool()
      Weaves Executors.newCachedThreadPool(), as newFixedThreadPool(int).
      Returns:
      the new pool
      Since:
      1.13.2
    • newCachedThreadPool

      public static ExecutorService newCachedThreadPool(ThreadFactory factory)
      Weaves Executors.newCachedThreadPool(ThreadFactory), as newFixedThreadPool(int).
      Parameters:
      factory - the thread factory
      Returns:
      the new pool
      Since:
      1.13.2
    • newSingleThreadExecutor

      public static ExecutorService newSingleThreadExecutor()
      Weaves Executors.newSingleThreadExecutor(), as newFixedThreadPool(int).
      Returns:
      the new executor
      Since:
      1.13.2
    • newSingleThreadExecutor

      public static ExecutorService newSingleThreadExecutor(ThreadFactory factory)
      Weaves Executors.newSingleThreadExecutor(ThreadFactory), as newFixedThreadPool(int).
      Parameters:
      factory - the thread factory
      Returns:
      the new executor
      Since:
      1.13.2
    • newScheduledThreadPool

      public static ScheduledExecutorService newScheduledThreadPool(int coreThreads)
      Weaves Executors.newScheduledThreadPool(int), as newFixedThreadPool(int).
      Parameters:
      coreThreads - the number of threads kept in the pool
      Returns:
      the new pool
      Since:
      1.13.2
    • newScheduledThreadPool

      public static ScheduledExecutorService newScheduledThreadPool(int coreThreads, ThreadFactory factory)
      Weaves Executors.newScheduledThreadPool(int, ThreadFactory), as newFixedThreadPool(int).
      Parameters:
      coreThreads - the number of threads kept in the pool
      factory - the thread factory
      Returns:
      the new pool
      Since:
      1.13.2
    • newSingleThreadScheduledExecutor

      public static ScheduledExecutorService newSingleThreadScheduledExecutor()
      Weaves Executors.newSingleThreadScheduledExecutor(), as newFixedThreadPool(int).
      Returns:
      the new executor
      Since:
      1.13.2
    • newSingleThreadScheduledExecutor

      public static ScheduledExecutorService newSingleThreadScheduledExecutor(ThreadFactory factory)
      Weaves Executors.newSingleThreadScheduledExecutor(ThreadFactory), as newFixedThreadPool(int).
      Parameters:
      factory - the thread factory
      Returns:
      the new executor
      Since:
      1.13.2
    • newWorkStealingPool

      public static ExecutorService newWorkStealingPool()
      Weaves Executors.newWorkStealingPool(), as newFixedThreadPool(int).
      Returns:
      the new pool
      Since:
      1.13.2
    • newWorkStealingPool

      public static ExecutorService newWorkStealingPool(int parallelism)
      Weaves Executors.newWorkStealingPool(int), as newFixedThreadPool(int).
      Parameters:
      parallelism - the targeted parallelism level
      Returns:
      the new pool
      Since:
      1.13.2
    • newVirtualThreadPerTaskExecutor

      public static ExecutorService newVirtualThreadPerTaskExecutor()
      Weaves Executors.newVirtualThreadPerTaskExecutor(), as newFixedThreadPool(int).
      Returns:
      the new executor
      Since:
      1.13.2
    • newThreadPerTaskExecutor

      public static ExecutorService newThreadPerTaskExecutor(ThreadFactory factory)
      Weaves Executors.newThreadPerTaskExecutor(ThreadFactory), as newFixedThreadPool(int).
      Parameters:
      factory - the factory each task's thread comes from
      Returns:
      the new executor
      Since:
      1.13.2
    • unconfigurableExecutorService

      public static ExecutorService unconfigurableExecutorService(ExecutorService executor)
      Weaves Executors.unconfigurableExecutorService(ExecutorService): remembers what the wrapper forwards to, so a woven execute on it decides by the executor behind it (#1107). kotlinx's newSingleThreadContext wraps a ScheduledThreadPoolExecutor this way, and without the look-through nothing its thread did reached a detector.
      Parameters:
      executor - the executor to wrap
      Returns:
      what the JDK returns
      Since:
      1.14.1
    • unconfigurableScheduledExecutorService

      public static ScheduledExecutorService unconfigurableScheduledExecutorService(ScheduledExecutorService executor)
      Weaves Executors.unconfigurableScheduledExecutorService(ScheduledExecutorService), as unconfigurableExecutorService(java.util.concurrent.ExecutorService).
      Parameters:
      executor - the executor to wrap
      Returns:
      what the JDK returns
      Since:
      1.14.1
    • exchange

      public static @Nullable Object exchange(Exchanger<Object> receiver, @Nullable Object item) throws InterruptedException
      Weaves Exchanger.exchange(Object): this thread's accesses are published through the object it hands over, and it receives what its partner published through the one it got back (#741). An exchange that threw handed nothing over, and its release is withdrawn.
      Parameters:
      receiver - the exchanger
      item - the object handed over
      Returns:
      the partner's object
      Throws:
      InterruptedException - if interrupted while waiting
      Since:
      1.12.3
    • exchange

      public static @Nullable Object exchange(Exchanger<Object> receiver, @Nullable Object item, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException
      Weaves Exchanger.exchange(Object, long, TimeUnit), as exchange(Exchanger, Object); one that timed out handed nothing over.
      Parameters:
      receiver - the exchanger
      item - the object handed over
      timeout - how long to wait for a partner
      unit - the unit of timeout
      Returns:
      the partner's object
      Throws:
      InterruptedException - if interrupted while waiting
      TimeoutException - if no partner arrived in time
      Since:
      1.12.3
    • execute

      public static void execute(Executor receiver, Runnable command)
      Weaves Executor.execute(Runnable) (#741, #834): on an executor that never hands the task back, the task runs as a AgentHandOffHooks.HandedTask, so it starts ordered after this call, and the thread running it is attributed to the run while it does. There is no future, so nothing is ordered after the task.

      Only the JDK's own ForkJoinPool, ScheduledThreadPoolExecutor and the thread-per-task executor behind Executors.newVirtualThreadPerTaskExecutor() qualify, by exact class: the first runs it inside its own adapter and returns no queued task from shutdownNow, the second queues its own futures, and the third queues nothing. A ThreadPoolExecutor qualifies too, inside a run (#1155), and so does a subclass that overrides none of the methods a task reaches (#1173), and a wrapper Executors built around any of these (#1107, #1269); see executesInvisibly(java.util.concurrent.Executor). Any other subclass's tasks are left alone, since its beforeExecute would see the wrapper, as are those of any executor outside the JDK's.

      Parameters:
      receiver - the executor the call site invoked
      command - what to run; the executor rejects null
      Since:
      1.12.4
    • streamForEach

      public static void streamForEach(Stream<Object> receiver, Consumer<Object> action)
      Weaves Stream.forEach: see AgentConcurrencyUtilHooks.ParallelForEach. A sequential stream, or one outside a run, takes the call as it was (#1156).
      Parameters:
      receiver - the stream
      action - what to run for each element
      Since:
      1.14.1
    • concurrentMapForEach

      public static void concurrentMapForEach(ConcurrentHashMap<Object,Object> receiver, long parallelismThreshold, BiConsumer<Object,Object> action)
      Weaves ConcurrentHashMap.forEach(long, BiConsumer): the common pool's workers run the action once the map holds at least parallelismThreshold mappings, so each runs as an element of a AgentConcurrencyUtilHooks.ParallelForEach. Outside a run the call is as it was.
      Parameters:
      receiver - the map
      parallelismThreshold - the size from which the map splits the work across the pool
      action - what to run for each mapping
      Since:
      1.14.3
    • concurrentMapForEachKey

      public static void concurrentMapForEachKey(ConcurrentHashMap<Object,Object> receiver, long parallelismThreshold, Consumer<Object> action)
      Parameters:
      receiver - the map
      parallelismThreshold - the size from which the map splits the work across the pool
      action - what to run for each key
      Since:
      1.14.3
    • concurrentMapForEachValue

      public static void concurrentMapForEachValue(ConcurrentHashMap<Object,Object> receiver, long parallelismThreshold, Consumer<Object> action)
      Parameters:
      receiver - the map
      parallelismThreshold - the size from which the map splits the work across the pool
      action - what to run for each value
      Since:
      1.14.3
    • concurrentMapForEachEntry

      public static void concurrentMapForEachEntry(ConcurrentHashMap<Object,Object> receiver, long parallelismThreshold, Consumer<Map.Entry<Object,Object>> action)
      Parameters:
      receiver - the map
      parallelismThreshold - the size from which the map splits the work across the pool
      action - what to run for each entry
      Since:
      1.14.3
    • concurrentMapForEach

      public static void concurrentMapForEach(ConcurrentHashMap<Object,Object> receiver, long parallelismThreshold, BiFunction<Object,Object,Object> transformer, Consumer<Object> action)
      Weaves ConcurrentHashMap.forEach(long, BiFunction, Consumer), as concurrentMapForEach(java.util.concurrent.ConcurrentHashMap<java.lang.Object, java.lang.Object>, long, java.util.function.BiConsumer<java.lang.Object, java.lang.Object>): the transformer and the action each run as an element.
      Parameters:
      receiver - the map
      parallelismThreshold - the size from which the map splits the work across the pool
      transformer - what turns each mapping into the action's input, or null to skip it
      action - what to run for each non-null transformation
      Since:
      1.14.3
    • concurrentMapForEachKey

      public static void concurrentMapForEachKey(ConcurrentHashMap<Object,Object> receiver, long parallelismThreshold, Function<Object,Object> transformer, Consumer<Object> action)
      Parameters:
      receiver - the map
      parallelismThreshold - the size from which the map splits the work across the pool
      transformer - what turns each key into the action's input, or null to skip it
      action - what to run for each non-null transformation
      Since:
      1.14.3
    • concurrentMapForEachValue

      public static void concurrentMapForEachValue(ConcurrentHashMap<Object,Object> receiver, long parallelismThreshold, Function<Object,Object> transformer, Consumer<Object> action)
      Parameters:
      receiver - the map
      parallelismThreshold - the size from which the map splits the work across the pool
      transformer - what turns each value into the action's input, or null to skip it
      action - what to run for each non-null transformation
      Since:
      1.14.3
    • concurrentMapForEachEntry

      public static void concurrentMapForEachEntry(ConcurrentHashMap<Object,Object> receiver, long parallelismThreshold, Function<Map.Entry<Object,Object>,Object> transformer, Consumer<Object> action)
      Parameters:
      receiver - the map
      parallelismThreshold - the size from which the map splits the work across the pool
      transformer - what turns each entry into the action's input, or null to skip it
      action - what to run for each non-null transformation
      Since:
      1.14.3
    • arraysParallelSetAll

      public static void arraysParallelSetAll(Object[] array, IntFunction<Object> generator)
      Weaves Arrays.parallelSetAll(Object[], IntFunction): the common pool's workers call the generator, so each call runs as an element of a AgentConcurrencyUtilHooks.ParallelForEach. Outside a run the call is as it was.
      Parameters:
      array - the array to fill
      generator - what computes the value at each index
      Since:
      1.14.3
    • arraysParallelSetAll

      public static void arraysParallelSetAll(int[] array, IntUnaryOperator generator)
      Weaves Arrays.parallelSetAll(int[], IntUnaryOperator), as the Object[] form.
      Parameters:
      array - the array to fill
      generator - what computes the value at each index
      Since:
      1.14.3
    • arraysParallelSetAll

      public static void arraysParallelSetAll(long[] array, IntToLongFunction generator)
      Weaves Arrays.parallelSetAll(long[], IntToLongFunction), as the Object[] form.
      Parameters:
      array - the array to fill
      generator - what computes the value at each index
      Since:
      1.14.3
    • arraysParallelSetAll

      public static void arraysParallelSetAll(double[] array, IntToDoubleFunction generator)
      Weaves Arrays.parallelSetAll(double[], IntToDoubleFunction), as the Object[] form.
      Parameters:
      array - the array to fill
      generator - what computes the value at each index
      Since:
      1.14.3
    • streamMap

      public static Stream<Object> streamMap(Stream<Object> receiver, Function<Object,Object> mapper)
      Weaves Stream.map: see AgentConcurrencyUtilHooks.StageSlot. Outside a run the call is as it was.
      Parameters:
      receiver - the stream
      mapper - the function given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • streamFilter

      public static Stream<Object> streamFilter(Stream<Object> receiver, Predicate<Object> predicate)
      Parameters:
      receiver - the stream
      predicate - what keeps an element
      Returns:
      the filtered stream
      Since:
      1.14.2
    • streamPeek

      public static Stream<Object> streamPeek(Stream<Object> receiver, Consumer<Object> action)
      Parameters:
      receiver - the stream
      action - what to run for each element as it passes
      Returns:
      the peeked stream
      Since:
      1.14.2
    • streamForEachOrdered

      public static void streamForEachOrdered(Stream<Object> receiver, Consumer<Object> action)
      Weaves Stream.forEachOrdered, as streamForEach(java.util.stream.Stream<java.lang.Object>, java.util.function.Consumer<java.lang.Object>), with each action ordered after the one before it (AgentConcurrencyUtilHooks.ParallelForEach.ordered(java.lang.Runnable)).
      Parameters:
      receiver - the stream
      action - what to run for each element, in encounter order
      Since:
      1.14.2
    • streamCollect

      public static Object streamCollect(Stream<Object> receiver, Collector<? super Object,?,?> collector)
      Weaves Stream.collect(Collector): the pipeline's woven stages run as its elements. The collector's own functions are left as they are; the JDK's run no woven code.
      Parameters:
      receiver - the stream
      collector - what accumulates the elements, run as it is
      Returns:
      what the collector produced
      Since:
      1.14.2
    • streamCollect

      public static Object streamCollect(Stream<Object> receiver, Supplier<Object> supplier, BiConsumer<Object,Object> accumulator, BiConsumer<Object,Object> combiner)
      Weaves Stream.collect(Supplier, BiConsumer, BiConsumer): supplier and accumulator run as elements, and the combiner, which merges containers other subtasks filled, as a combine.
      Parameters:
      receiver - the stream
      supplier - makes a container
      accumulator - adds an element to one
      combiner - merges two
      Returns:
      the container
      Since:
      1.14.2
    • streamReduce

      public static Optional<Object> streamReduce(Stream<Object> receiver, BinaryOperator<Object> accumulator)
      Weaves Stream.reduce(BinaryOperator): the accumulator runs as a combine, since it also merges partial results other subtasks built (AgentConcurrencyUtilHooks.ParallelForEach.combined(java.lang.Runnable)).
      Parameters:
      receiver - the stream
      accumulator - combines two values
      Returns:
      the reduction, if any element
      Since:
      1.14.2
    • streamReduce

      public static Object streamReduce(Stream<Object> receiver, Object identity, BinaryOperator<Object> accumulator)
      Weaves Stream.reduce(Object, BinaryOperator), as streamReduce(Stream, BinaryOperator).
      Parameters:
      receiver - the stream
      identity - the identity value
      accumulator - combines two values
      Returns:
      the reduction
      Since:
      1.14.2
    • streamReduce

      public static Object streamReduce(Stream<Object> receiver, Object identity, BiFunction<Object,Object,Object> accumulator, BinaryOperator<Object> combiner)
      Weaves Stream.reduce(Object, BiFunction, BinaryOperator): the accumulator runs as an element and the combiner as a combine.
      Parameters:
      receiver - the stream
      identity - the identity value
      accumulator - folds an element into a partial result
      combiner - merges two partial results
      Returns:
      the reduction
      Since:
      1.14.2
    • streamMin

      public static Optional<Object> streamMin(Stream<Object> receiver, Comparator<Object> comparator)
      Weaves Stream.min(Comparator): the comparator runs as a combine, since it compares elements other subtasks produced.
      Parameters:
      receiver - the stream
      comparator - orders two values
      Returns:
      the least, if any element
      Since:
      1.14.2
    • streamMax

      public static Optional<Object> streamMax(Stream<Object> receiver, Comparator<Object> comparator)
      Parameters:
      receiver - the stream
      comparator - orders two values
      Returns:
      the greatest, if any element
      Since:
      1.14.2
    • streamAnyMatch

      public static boolean streamAnyMatch(Stream<Object> receiver, Predicate<Object> predicate)
      Weaves Stream.anyMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether any element passed
      Since:
      1.14.2
    • streamAllMatch

      public static boolean streamAllMatch(Stream<Object> receiver, Predicate<Object> predicate)
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether every element passed
      Since:
      1.14.2
    • streamNoneMatch

      public static boolean streamNoneMatch(Stream<Object> receiver, Predicate<Object> predicate)
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether no element passed
      Since:
      1.14.2
    • streamToList

      public static List<Object> streamToList(Stream<Object> receiver)
      Weaves Stream.toList(): the pipeline's woven stages run as its elements.
      Parameters:
      receiver - the stream
      Returns:
      the elements
      Since:
      1.14.2
    • streamToArray

      public static Object[] streamToArray(Stream<Object> receiver)
      Parameters:
      receiver - the stream
      Returns:
      the elements
      Since:
      1.14.2
    • streamToArray

      public static Object[] streamToArray(Stream<Object> receiver, IntFunction<Object[]> generator)
      Weaves Stream.toArray(IntFunction), as streamToList(java.util.stream.Stream<java.lang.Object>); the generator is the array constructor nearly always and is left as it is.
      Parameters:
      receiver - the stream
      generator - makes the array
      Returns:
      the elements
      Since:
      1.14.2
    • streamCount

      public static long streamCount(Stream<Object> receiver)
      Parameters:
      receiver - the stream
      Returns:
      how many elements
      Since:
      1.14.2
    • streamFindFirst

      public static Optional<Object> streamFindFirst(Stream<Object> receiver)
      Parameters:
      receiver - the stream
      Returns:
      the first element, if any
      Since:
      1.14.2
    • streamFindAny

      public static Optional<Object> streamFindAny(Stream<Object> receiver)
      Parameters:
      receiver - the stream
      Returns:
      some element, if any
      Since:
      1.14.2
    • intStreamForEach

      public static void intStreamForEach(IntStream receiver, IntConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element
      Since:
      1.14.1
    • longStreamForEach

      public static void longStreamForEach(LongStream receiver, LongConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element
      Since:
      1.14.1
    • doubleStreamForEach

      public static void doubleStreamForEach(DoubleStream receiver, DoubleConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element
      Since:
      1.14.1
    • streamSorted

      public static Stream<Object> streamSorted(Stream<Object> receiver)
      Weaves Stream.sorted: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • streamDistinct

      public static Stream<Object> streamDistinct(Stream<Object> receiver)
      Weaves Stream.distinct: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • streamLimit

      public static Stream<Object> streamLimit(Stream<Object> receiver, long maxSize)
      Weaves Stream.limit: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      maxSize - how many to keep
      Returns:
      the stream
      Since:
      1.14.2
    • streamSkip

      public static Stream<Object> streamSkip(Stream<Object> receiver, long n)
      Weaves Stream.skip: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      n - how many to drop
      Returns:
      the stream
      Since:
      1.14.2
    • streamParallel

      public static BaseStream<?,?> streamParallel(Stream<Object> receiver)
      Weaves Stream.parallel: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream; declared by BaseStream, so the call site expects one
      Since:
      1.14.2
    • streamSequential

      public static BaseStream<?,?> streamSequential(Stream<Object> receiver)
      Weaves Stream.sequential: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream; declared by BaseStream, so the call site expects one
      Since:
      1.14.2
    • streamUnordered

      public static BaseStream<?,?> streamUnordered(Stream<Object> receiver)
      Weaves Stream.unordered: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream; declared by BaseStream, so the call site expects one
      Since:
      1.14.2
    • streamSorted

      public static Stream<Object> streamSorted(Stream<Object> receiver, Comparator<Object> comparator)
      Weaves Stream.sorted: the comparator runs as a combine, since a parallel sort compares elements other subtasks produced.
      Parameters:
      receiver - the stream
      comparator - orders two elements; the sort calls it on pool workers
      Returns:
      the stream it returns
      Since:
      1.14.2
    • streamFlatMap

      public static Stream<Object> streamFlatMap(Stream<Object> receiver, Function<Object,Stream<Object>> mapper)
      Weaves Stream.flatMap: the mapper runs as an element; the stream it returns is consumed inside that element.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • streamMapMulti

      public static Stream<Object> streamMapMulti(Stream<Object> receiver, BiConsumer<Object,Consumer<Object>> mapper)
      Weaves Stream.mapMulti: the mapper runs as an element, and the values it passes on go downstream inside it (#1172).
      Parameters:
      receiver - the stream
      mapper - the function given each element and the sink for what it maps to
      Returns:
      the stream it returns
      Since:
      1.14.3
    • streamMapMultiToInt

      public static IntStream streamMapMultiToInt(Stream<Object> receiver, BiConsumer<Object,IntConsumer> mapper)
      Parameters:
      receiver - the stream
      mapper - the function given each element and the sink for what it maps to
      Returns:
      the stream it returns
      Since:
      1.14.3
    • streamMapMultiToLong

      public static LongStream streamMapMultiToLong(Stream<Object> receiver, BiConsumer<Object,LongConsumer> mapper)
      Parameters:
      receiver - the stream
      mapper - the function given each element and the sink for what it maps to
      Returns:
      the stream it returns
      Since:
      1.14.3
    • streamMapMultiToDouble

      public static DoubleStream streamMapMultiToDouble(Stream<Object> receiver, BiConsumer<Object,DoubleConsumer> mapper)
      Parameters:
      receiver - the stream
      mapper - the function given each element and the sink for what it maps to
      Returns:
      the stream it returns
      Since:
      1.14.3
    • intStreamMapMulti

      public static IntStream intStreamMapMulti(IntStream receiver, IntStream.IntMapMultiConsumer mapper)
      Parameters:
      receiver - the stream
      mapper - the function given each element and the sink for what it maps to
      Returns:
      the stream it returns
      Since:
      1.14.3
    • longStreamMapMulti

      public static LongStream longStreamMapMulti(LongStream receiver, LongStream.LongMapMultiConsumer mapper)
      Parameters:
      receiver - the stream
      mapper - the function given each element and the sink for what it maps to
      Returns:
      the stream it returns
      Since:
      1.14.3
    • doubleStreamMapMulti

      public static DoubleStream doubleStreamMapMulti(DoubleStream receiver, DoubleStream.DoubleMapMultiConsumer mapper)
      Parameters:
      receiver - the stream
      mapper - the function given each element and the sink for what it maps to
      Returns:
      the stream it returns
      Since:
      1.14.3
    • intStreamUnordered

      public static BaseStream<?,?> intStreamUnordered(IntStream receiver)
      Weaves IntStream.unordered, which IntStream inherits from BaseStream: it runs no lambda of its own and carries the woven stages behind it (#1172).
      Parameters:
      receiver - the stream
      Returns:
      the stream it returns
      Since:
      1.14.3
    • longStreamUnordered

      public static BaseStream<?,?> longStreamUnordered(LongStream receiver)
      Weaves LongStream.unordered, as intStreamUnordered(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      the stream it returns
      Since:
      1.14.3
    • doubleStreamUnordered

      public static BaseStream<?,?> doubleStreamUnordered(DoubleStream receiver)
      Weaves DoubleStream.unordered, as intStreamUnordered(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      the stream it returns
      Since:
      1.14.3
    • streamOnClose

      public static BaseStream<?,?> streamOnClose(Stream<Object> receiver, Runnable closeHandler)
      Weaves Stream.onClose: the close handler runs at close(), not in the pipeline, so it carries the woven stages behind it like a stage with no lambda (#1172).
      Parameters:
      receiver - the stream
      closeHandler - what close() runs
      Returns:
      the stream it returns
      Since:
      1.14.3
    • intStreamOnClose

      public static BaseStream<?,?> intStreamOnClose(IntStream receiver, Runnable closeHandler)
      Parameters:
      receiver - the stream
      closeHandler - what close() runs
      Returns:
      the stream it returns
      Since:
      1.14.3
    • longStreamOnClose

      public static BaseStream<?,?> longStreamOnClose(LongStream receiver, Runnable closeHandler)
      Parameters:
      receiver - the stream
      closeHandler - what close() runs
      Returns:
      the stream it returns
      Since:
      1.14.3
    • doubleStreamOnClose

      public static BaseStream<?,?> doubleStreamOnClose(DoubleStream receiver, Runnable closeHandler)
      Parameters:
      receiver - the stream
      closeHandler - what close() runs
      Returns:
      the stream it returns
      Since:
      1.14.3
    • streamIterator

      public static Iterator<Object> streamIterator(Stream<Object> receiver)
      Weaves Stream.iterator(): see AgentConcurrencyUtilHooks.LentPipeline. A sequential pipeline, one with no woven stage, or one outside a run is iterated as it was.
      Parameters:
      receiver - the stream
      Returns:
      the iterator over its elements
      Since:
      1.14.3
    • intStreamIterator

      public static PrimitiveIterator.OfInt intStreamIterator(IntStream receiver)
      Parameters:
      receiver - the stream
      Returns:
      the iterator over its elements
      Since:
      1.14.3
    • longStreamIterator

      public static PrimitiveIterator.OfLong longStreamIterator(LongStream receiver)
      Parameters:
      receiver - the stream
      Returns:
      the iterator over its elements
      Since:
      1.14.3
    • doubleStreamIterator

      public static PrimitiveIterator.OfDouble doubleStreamIterator(DoubleStream receiver)
      Parameters:
      receiver - the stream
      Returns:
      the iterator over its elements
      Since:
      1.14.3
    • streamTakeWhile

      public static Stream<Object> streamTakeWhile(Stream<Object> receiver, Predicate<Object> predicate)
      Weaves Stream.takeWhile: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • streamDropWhile

      public static Stream<Object> streamDropWhile(Stream<Object> receiver, Predicate<Object> predicate)
      Weaves Stream.dropWhile: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • intStreamSorted

      public static IntStream intStreamSorted(IntStream receiver)
      Weaves IntStream.sorted: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • intStreamDistinct

      public static IntStream intStreamDistinct(IntStream receiver)
      Weaves IntStream.distinct: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • intStreamLimit

      public static IntStream intStreamLimit(IntStream receiver, long maxSize)
      Weaves IntStream.limit: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      maxSize - how many to keep
      Returns:
      the stream
      Since:
      1.14.2
    • intStreamSkip

      public static IntStream intStreamSkip(IntStream receiver, long n)
      Weaves IntStream.skip: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      n - how many to drop
      Returns:
      the stream
      Since:
      1.14.2
    • intStreamParallel

      public static IntStream intStreamParallel(IntStream receiver)
      Weaves IntStream.parallel: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • intStreamSequential

      public static IntStream intStreamSequential(IntStream receiver)
      Weaves IntStream.sequential: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • intStreamFlatMap

      public static IntStream intStreamFlatMap(IntStream receiver, IntFunction<IntStream> mapper)
      Weaves IntStream.flatMap: the mapper runs as an element; the stream it returns is consumed inside that element.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • intStreamTakeWhile

      public static IntStream intStreamTakeWhile(IntStream receiver, IntPredicate predicate)
      Weaves IntStream.takeWhile: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • intStreamDropWhile

      public static IntStream intStreamDropWhile(IntStream receiver, IntPredicate predicate)
      Weaves IntStream.dropWhile: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • intStreamMapToLong

      public static LongStream intStreamMapToLong(IntStream receiver, IntToLongFunction mapper)
      Weaves IntStream.mapToLong: the mapper runs as an element, and the stages behind it stay in the pipeline the returned LongStream ends.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • intStreamMapToDouble

      public static DoubleStream intStreamMapToDouble(IntStream receiver, IntToDoubleFunction mapper)
      Weaves IntStream.mapToDouble: the mapper runs as an element, and the stages behind it stay in the pipeline the returned DoubleStream ends.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • intStreamAsLongStream

      public static LongStream intStreamAsLongStream(IntStream receiver)
      Weaves IntStream.asLongStream: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • intStreamAsDoubleStream

      public static DoubleStream intStreamAsDoubleStream(IntStream receiver)
      Weaves IntStream.asDoubleStream: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • longStreamSorted

      public static LongStream longStreamSorted(LongStream receiver)
      Weaves LongStream.sorted: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • longStreamDistinct

      public static LongStream longStreamDistinct(LongStream receiver)
      Weaves LongStream.distinct: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • longStreamLimit

      public static LongStream longStreamLimit(LongStream receiver, long maxSize)
      Weaves LongStream.limit: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      maxSize - how many to keep
      Returns:
      the stream
      Since:
      1.14.2
    • longStreamSkip

      public static LongStream longStreamSkip(LongStream receiver, long n)
      Weaves LongStream.skip: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      n - how many to drop
      Returns:
      the stream
      Since:
      1.14.2
    • longStreamParallel

      public static LongStream longStreamParallel(LongStream receiver)
      Weaves LongStream.parallel: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • longStreamSequential

      public static LongStream longStreamSequential(LongStream receiver)
      Weaves LongStream.sequential: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • longStreamFlatMap

      public static LongStream longStreamFlatMap(LongStream receiver, LongFunction<LongStream> mapper)
      Weaves LongStream.flatMap: the mapper runs as an element; the stream it returns is consumed inside that element.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • longStreamTakeWhile

      public static LongStream longStreamTakeWhile(LongStream receiver, LongPredicate predicate)
      Weaves LongStream.takeWhile: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • longStreamDropWhile

      public static LongStream longStreamDropWhile(LongStream receiver, LongPredicate predicate)
      Weaves LongStream.dropWhile: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • longStreamMapToInt

      public static IntStream longStreamMapToInt(LongStream receiver, LongToIntFunction mapper)
      Weaves LongStream.mapToInt: the mapper runs as an element, and the stages behind it stay in the pipeline the returned IntStream ends.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • longStreamMapToDouble

      public static DoubleStream longStreamMapToDouble(LongStream receiver, LongToDoubleFunction mapper)
      Weaves LongStream.mapToDouble: the mapper runs as an element, and the stages behind it stay in the pipeline the returned DoubleStream ends.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • longStreamAsDoubleStream

      public static DoubleStream longStreamAsDoubleStream(LongStream receiver)
      Weaves LongStream.asDoubleStream: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • doubleStreamSorted

      public static DoubleStream doubleStreamSorted(DoubleStream receiver)
      Weaves DoubleStream.sorted: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • doubleStreamDistinct

      public static DoubleStream doubleStreamDistinct(DoubleStream receiver)
      Weaves DoubleStream.distinct: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • doubleStreamLimit

      public static DoubleStream doubleStreamLimit(DoubleStream receiver, long maxSize)
      Weaves DoubleStream.limit: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      maxSize - how many to keep
      Returns:
      the stream
      Since:
      1.14.2
    • doubleStreamSkip

      public static DoubleStream doubleStreamSkip(DoubleStream receiver, long n)
      Weaves DoubleStream.skip: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      n - how many to drop
      Returns:
      the stream
      Since:
      1.14.2
    • doubleStreamParallel

      public static DoubleStream doubleStreamParallel(DoubleStream receiver)
      Weaves DoubleStream.parallel: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • doubleStreamSequential

      public static DoubleStream doubleStreamSequential(DoubleStream receiver)
      Weaves DoubleStream.sequential: it runs no lambda of its own and carries the woven stages behind it to the stream it returns, so the terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the stream
      Since:
      1.14.2
    • doubleStreamFlatMap

      public static DoubleStream doubleStreamFlatMap(DoubleStream receiver, DoubleFunction<DoubleStream> mapper)
      Weaves DoubleStream.flatMap: the mapper runs as an element; the stream it returns is consumed inside that element.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • doubleStreamTakeWhile

      public static DoubleStream doubleStreamTakeWhile(DoubleStream receiver, DoublePredicate predicate)
      Weaves DoubleStream.takeWhile: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • doubleStreamDropWhile

      public static DoubleStream doubleStreamDropWhile(DoubleStream receiver, DoublePredicate predicate)
      Weaves DoubleStream.dropWhile: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • doubleStreamMapToInt

      public static IntStream doubleStreamMapToInt(DoubleStream receiver, DoubleToIntFunction mapper)
      Weaves DoubleStream.mapToInt: the mapper runs as an element, and the stages behind it stay in the pipeline the returned IntStream ends.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • doubleStreamMapToLong

      public static LongStream doubleStreamMapToLong(DoubleStream receiver, DoubleToLongFunction mapper)
      Weaves DoubleStream.mapToLong: the mapper runs as an element, and the stages behind it stay in the pipeline the returned LongStream ends.
      Parameters:
      receiver - the stream
      mapper - the lambda given to each element
      Returns:
      the stream it returns
      Since:
      1.14.2
    • streamMapToInt

      public static IntStream streamMapToInt(Stream<Object> receiver, ToIntFunction<Object> mapper)
      Weaves Stream.mapToInt, as streamMap(java.util.stream.Stream<java.lang.Object>, java.util.function.Function<java.lang.Object, java.lang.Object>); the stages behind it stay in the pipeline the returned IntStream ends.
      Parameters:
      receiver - the stream
      mapper - the function given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • streamMapToLong

      public static LongStream streamMapToLong(Stream<Object> receiver, ToLongFunction<Object> mapper)
      Weaves Stream.mapToLong, as streamMap(java.util.stream.Stream<java.lang.Object>, java.util.function.Function<java.lang.Object, java.lang.Object>); the stages behind it stay in the pipeline the returned LongStream ends.
      Parameters:
      receiver - the stream
      mapper - the function given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • streamMapToDouble

      public static DoubleStream streamMapToDouble(Stream<Object> receiver, ToDoubleFunction<Object> mapper)
      Weaves Stream.mapToDouble, as streamMap(java.util.stream.Stream<java.lang.Object>, java.util.function.Function<java.lang.Object, java.lang.Object>); the stages behind it stay in the pipeline the returned DoubleStream ends.
      Parameters:
      receiver - the stream
      mapper - the function given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • intStreamMap

      public static IntStream intStreamMap(IntStream receiver, IntUnaryOperator mapper)
      Weaves IntStream.map, as streamMap(java.util.stream.Stream<java.lang.Object>, java.util.function.Function<java.lang.Object, java.lang.Object>): the operator waits in a slot the terminal operation lends the run to.
      Parameters:
      receiver - the stream
      mapper - the operator given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • intStreamFilter

      public static IntStream intStreamFilter(IntStream receiver, IntPredicate predicate)
      Parameters:
      receiver - the stream
      predicate - what keeps an element
      Returns:
      the filtered stream
      Since:
      1.14.2
    • intStreamPeek

      public static IntStream intStreamPeek(IntStream receiver, IntConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element as it passes
      Returns:
      the peeked stream
      Since:
      1.14.2
    • intStreamMapToObj

      public static Stream<Object> intStreamMapToObj(IntStream receiver, IntFunction<Object> mapper)
      Weaves IntStream.mapToObj, as streamMap(java.util.stream.Stream<java.lang.Object>, java.util.function.Function<java.lang.Object, java.lang.Object>); the stages behind it stay in the pipeline the returned Stream ends.
      Parameters:
      receiver - the stream
      mapper - the function given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • intStreamBoxed

      public static Stream<Object> intStreamBoxed(IntStream receiver)
      Weaves IntStream.boxed: it adds no lambda of its own, and carries the stages behind it to the Stream it returns, so a woven Stream terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the elements as Integer
      Since:
      1.14.2
    • intStreamForEachOrdered

      public static void intStreamForEachOrdered(IntStream receiver, IntConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element, in encounter order
      Since:
      1.14.2
    • intStreamReduce

      public static int intStreamReduce(IntStream receiver, int identity, IntBinaryOperator operator)
      Weaves IntStream.reduce(int, IntBinaryOperator): the operator runs as a combine, since it also merges partial results other subtasks built (AgentConcurrencyUtilHooks.ParallelForEach.combined(java.lang.Runnable)).
      Parameters:
      receiver - the stream
      identity - the identity value
      operator - combines two values
      Returns:
      the reduction
      Since:
      1.14.2
    • intStreamReduce

      public static OptionalInt intStreamReduce(IntStream receiver, IntBinaryOperator operator)
      Weaves IntStream.reduce(IntBinaryOperator), as the reduce with an identity.
      Parameters:
      receiver - the stream
      operator - combines two values
      Returns:
      the reduction, if any element
      Since:
      1.14.2
    • intStreamCollect

      public static Object intStreamCollect(IntStream receiver, Supplier<Object> supplier, ObjIntConsumer<Object> accumulator, BiConsumer<Object,Object> combiner)
      Weaves IntStream.collect: supplier and accumulator run as elements, and the combiner, which merges containers other subtasks filled, as a combine.
      Parameters:
      receiver - the stream
      supplier - makes a container
      accumulator - adds an element to one
      combiner - merges two
      Returns:
      the container
      Since:
      1.14.2
    • intStreamAnyMatch

      public static boolean intStreamAnyMatch(IntStream receiver, IntPredicate predicate)
      Weaves IntStream.anyMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether any element passed
      Since:
      1.14.2
    • intStreamAllMatch

      public static boolean intStreamAllMatch(IntStream receiver, IntPredicate predicate)
      Weaves IntStream.allMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether every element passed
      Since:
      1.14.2
    • intStreamNoneMatch

      public static boolean intStreamNoneMatch(IntStream receiver, IntPredicate predicate)
      Weaves IntStream.noneMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether no element passed
      Since:
      1.14.2
    • intStreamSum

      public static int intStreamSum(IntStream receiver)
      Weaves IntStream.sum(): the pipeline's woven stages run as its elements, and the caller is ordered after them once it returns.
      Parameters:
      receiver - the stream
      Returns:
      the sum of the elements
      Since:
      1.14.2
    • intStreamCount

      public static long intStreamCount(IntStream receiver)
      Weaves IntStream.count(), as intStreamSum(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      how many elements
      Since:
      1.14.2
    • intStreamAverage

      public static OptionalDouble intStreamAverage(IntStream receiver)
      Weaves IntStream.average(), as intStreamSum(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      the mean, if any element
      Since:
      1.14.2
    • intStreamMin

      public static OptionalInt intStreamMin(IntStream receiver)
      Weaves IntStream.min(), as intStreamSum(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      the least, if any element
      Since:
      1.14.2
    • intStreamMax

      public static OptionalInt intStreamMax(IntStream receiver)
      Weaves IntStream.max(), as intStreamSum(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      the greatest, if any element
      Since:
      1.14.2
    • intStreamSummaryStatistics

      public static IntSummaryStatistics intStreamSummaryStatistics(IntStream receiver)
      Weaves IntStream.summaryStatistics(), as intStreamSum(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      count, sum, least, greatest and mean
      Since:
      1.14.2
    • intStreamToArray

      public static int[] intStreamToArray(IntStream receiver)
      Weaves IntStream.toArray(), as intStreamSum(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      the elements
      Since:
      1.14.2
    • intStreamFindFirst

      public static OptionalInt intStreamFindFirst(IntStream receiver)
      Weaves IntStream.findFirst(), as intStreamSum(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      the first element, if any
      Since:
      1.14.2
    • intStreamFindAny

      public static OptionalInt intStreamFindAny(IntStream receiver)
      Weaves IntStream.findAny(), as intStreamSum(java.util.stream.IntStream).
      Parameters:
      receiver - the stream
      Returns:
      some element, if any
      Since:
      1.14.2
    • longStreamMap

      public static LongStream longStreamMap(LongStream receiver, LongUnaryOperator mapper)
      Weaves LongStream.map, as intStreamMap(java.util.stream.IntStream, java.util.function.IntUnaryOperator): the operator waits in a slot the terminal operation lends the run to.
      Parameters:
      receiver - the stream
      mapper - the operator given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • longStreamFilter

      public static LongStream longStreamFilter(LongStream receiver, LongPredicate predicate)
      Parameters:
      receiver - the stream
      predicate - what keeps an element
      Returns:
      the filtered stream
      Since:
      1.14.2
    • longStreamPeek

      public static LongStream longStreamPeek(LongStream receiver, LongConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element as it passes
      Returns:
      the peeked stream
      Since:
      1.14.2
    • longStreamMapToObj

      public static Stream<Object> longStreamMapToObj(LongStream receiver, LongFunction<Object> mapper)
      Weaves LongStream.mapToObj, as intStreamMapToObj(java.util.stream.IntStream, java.util.function.IntFunction<java.lang.Object>); the stages behind it stay in the pipeline the returned Stream ends.
      Parameters:
      receiver - the stream
      mapper - the function given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • longStreamBoxed

      public static Stream<Object> longStreamBoxed(LongStream receiver)
      Weaves LongStream.boxed: it adds no lambda of its own, and carries the stages behind it to the Stream it returns, so a woven Stream terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the elements as Long
      Since:
      1.14.2
    • longStreamForEachOrdered

      public static void longStreamForEachOrdered(LongStream receiver, LongConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element, in encounter order
      Since:
      1.14.2
    • longStreamReduce

      public static long longStreamReduce(LongStream receiver, long identity, LongBinaryOperator operator)
      Weaves LongStream.reduce(long, LongBinaryOperator): the operator runs as a combine, since it also merges partial results other subtasks built (AgentConcurrencyUtilHooks.ParallelForEach.combined(java.lang.Runnable)).
      Parameters:
      receiver - the stream
      identity - the identity value
      operator - combines two values
      Returns:
      the reduction
      Since:
      1.14.2
    • longStreamReduce

      public static OptionalLong longStreamReduce(LongStream receiver, LongBinaryOperator operator)
      Weaves LongStream.reduce(LongBinaryOperator), as the reduce with an identity.
      Parameters:
      receiver - the stream
      operator - combines two values
      Returns:
      the reduction, if any element
      Since:
      1.14.2
    • longStreamCollect

      public static Object longStreamCollect(LongStream receiver, Supplier<Object> supplier, ObjLongConsumer<Object> accumulator, BiConsumer<Object,Object> combiner)
      Weaves LongStream.collect: supplier and accumulator run as elements, and the combiner, which merges containers other subtasks filled, as a combine.
      Parameters:
      receiver - the stream
      supplier - makes a container
      accumulator - adds an element to one
      combiner - merges two
      Returns:
      the container
      Since:
      1.14.2
    • longStreamAnyMatch

      public static boolean longStreamAnyMatch(LongStream receiver, LongPredicate predicate)
      Weaves LongStream.anyMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether any element passed
      Since:
      1.14.2
    • longStreamAllMatch

      public static boolean longStreamAllMatch(LongStream receiver, LongPredicate predicate)
      Weaves LongStream.allMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether every element passed
      Since:
      1.14.2
    • longStreamNoneMatch

      public static boolean longStreamNoneMatch(LongStream receiver, LongPredicate predicate)
      Weaves LongStream.noneMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether no element passed
      Since:
      1.14.2
    • longStreamSum

      public static long longStreamSum(LongStream receiver)
      Weaves LongStream.sum(): the pipeline's woven stages run as its elements, and the caller is ordered after them once it returns.
      Parameters:
      receiver - the stream
      Returns:
      the sum of the elements
      Since:
      1.14.2
    • longStreamCount

      public static long longStreamCount(LongStream receiver)
      Weaves LongStream.count(), as longStreamSum(java.util.stream.LongStream).
      Parameters:
      receiver - the stream
      Returns:
      how many elements
      Since:
      1.14.2
    • longStreamAverage

      public static OptionalDouble longStreamAverage(LongStream receiver)
      Weaves LongStream.average(), as longStreamSum(java.util.stream.LongStream).
      Parameters:
      receiver - the stream
      Returns:
      the mean, if any element
      Since:
      1.14.2
    • longStreamMin

      public static OptionalLong longStreamMin(LongStream receiver)
      Weaves LongStream.min(), as longStreamSum(java.util.stream.LongStream).
      Parameters:
      receiver - the stream
      Returns:
      the least, if any element
      Since:
      1.14.2
    • longStreamMax

      public static OptionalLong longStreamMax(LongStream receiver)
      Weaves LongStream.max(), as longStreamSum(java.util.stream.LongStream).
      Parameters:
      receiver - the stream
      Returns:
      the greatest, if any element
      Since:
      1.14.2
    • longStreamSummaryStatistics

      public static LongSummaryStatistics longStreamSummaryStatistics(LongStream receiver)
      Weaves LongStream.summaryStatistics(), as longStreamSum(java.util.stream.LongStream).
      Parameters:
      receiver - the stream
      Returns:
      count, sum, least, greatest and mean
      Since:
      1.14.2
    • longStreamToArray

      public static long[] longStreamToArray(LongStream receiver)
      Weaves LongStream.toArray(), as longStreamSum(java.util.stream.LongStream).
      Parameters:
      receiver - the stream
      Returns:
      the elements
      Since:
      1.14.2
    • longStreamFindFirst

      public static OptionalLong longStreamFindFirst(LongStream receiver)
      Weaves LongStream.findFirst(), as longStreamSum(java.util.stream.LongStream).
      Parameters:
      receiver - the stream
      Returns:
      the first element, if any
      Since:
      1.14.2
    • longStreamFindAny

      public static OptionalLong longStreamFindAny(LongStream receiver)
      Weaves LongStream.findAny(), as longStreamSum(java.util.stream.LongStream).
      Parameters:
      receiver - the stream
      Returns:
      some element, if any
      Since:
      1.14.2
    • doubleStreamMap

      public static DoubleStream doubleStreamMap(DoubleStream receiver, DoubleUnaryOperator mapper)
      Weaves DoubleStream.map, as intStreamMap(java.util.stream.IntStream, java.util.function.IntUnaryOperator): the operator waits in a slot the terminal operation lends the run to.
      Parameters:
      receiver - the stream
      mapper - the operator given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • doubleStreamFilter

      public static DoubleStream doubleStreamFilter(DoubleStream receiver, DoublePredicate predicate)
      Parameters:
      receiver - the stream
      predicate - what keeps an element
      Returns:
      the filtered stream
      Since:
      1.14.2
    • doubleStreamPeek

      public static DoubleStream doubleStreamPeek(DoubleStream receiver, DoubleConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element as it passes
      Returns:
      the peeked stream
      Since:
      1.14.2
    • doubleStreamMapToObj

      public static Stream<Object> doubleStreamMapToObj(DoubleStream receiver, DoubleFunction<Object> mapper)
      Weaves DoubleStream.mapToObj, as intStreamMapToObj(java.util.stream.IntStream, java.util.function.IntFunction<java.lang.Object>); the stages behind it stay in the pipeline the returned Stream ends.
      Parameters:
      receiver - the stream
      mapper - the function given to each element
      Returns:
      the mapped stream
      Since:
      1.14.2
    • doubleStreamBoxed

      public static Stream<Object> doubleStreamBoxed(DoubleStream receiver)
      Weaves DoubleStream.boxed: it adds no lambda of its own, and carries the stages behind it to the Stream it returns, so a woven Stream terminal operation still lends them the run.
      Parameters:
      receiver - the stream
      Returns:
      the elements as Double
      Since:
      1.14.2
    • doubleStreamForEachOrdered

      public static void doubleStreamForEachOrdered(DoubleStream receiver, DoubleConsumer action)
      Parameters:
      receiver - the stream
      action - what to run for each element, in encounter order
      Since:
      1.14.2
    • doubleStreamReduce

      public static double doubleStreamReduce(DoubleStream receiver, double identity, DoubleBinaryOperator operator)
      Weaves DoubleStream.reduce(double, DoubleBinaryOperator): the operator runs as a combine, since it also merges partial results other subtasks built (AgentConcurrencyUtilHooks.ParallelForEach.combined(java.lang.Runnable)).
      Parameters:
      receiver - the stream
      identity - the identity value
      operator - combines two values
      Returns:
      the reduction
      Since:
      1.14.2
    • doubleStreamReduce

      public static OptionalDouble doubleStreamReduce(DoubleStream receiver, DoubleBinaryOperator operator)
      Weaves DoubleStream.reduce(DoubleBinaryOperator), as the reduce with an identity.
      Parameters:
      receiver - the stream
      operator - combines two values
      Returns:
      the reduction, if any element
      Since:
      1.14.2
    • doubleStreamCollect

      public static Object doubleStreamCollect(DoubleStream receiver, Supplier<Object> supplier, ObjDoubleConsumer<Object> accumulator, BiConsumer<Object,Object> combiner)
      Weaves DoubleStream.collect: supplier and accumulator run as elements, and the combiner, which merges containers other subtasks filled, as a combine.
      Parameters:
      receiver - the stream
      supplier - makes a container
      accumulator - adds an element to one
      combiner - merges two
      Returns:
      the container
      Since:
      1.14.2
    • doubleStreamAnyMatch

      public static boolean doubleStreamAnyMatch(DoubleStream receiver, DoublePredicate predicate)
      Weaves DoubleStream.anyMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether any element passed
      Since:
      1.14.2
    • doubleStreamAllMatch

      public static boolean doubleStreamAllMatch(DoubleStream receiver, DoublePredicate predicate)
      Weaves DoubleStream.allMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether every element passed
      Since:
      1.14.2
    • doubleStreamNoneMatch

      public static boolean doubleStreamNoneMatch(DoubleStream receiver, DoublePredicate predicate)
      Weaves DoubleStream.noneMatch: the predicate runs as an element.
      Parameters:
      receiver - the stream
      predicate - the test
      Returns:
      whether no element passed
      Since:
      1.14.2
    • doubleStreamSum

      public static double doubleStreamSum(DoubleStream receiver)
      Weaves DoubleStream.sum(): the pipeline's woven stages run as its elements, and the caller is ordered after them once it returns.
      Parameters:
      receiver - the stream
      Returns:
      the sum of the elements
      Since:
      1.14.2
    • doubleStreamCount

      public static long doubleStreamCount(DoubleStream receiver)
      Weaves DoubleStream.count(), as doubleStreamSum(java.util.stream.DoubleStream).
      Parameters:
      receiver - the stream
      Returns:
      how many elements
      Since:
      1.14.2
    • doubleStreamAverage

      public static OptionalDouble doubleStreamAverage(DoubleStream receiver)
      Weaves DoubleStream.average(), as doubleStreamSum(java.util.stream.DoubleStream).
      Parameters:
      receiver - the stream
      Returns:
      the mean, if any element
      Since:
      1.14.2
    • doubleStreamMin

      public static OptionalDouble doubleStreamMin(DoubleStream receiver)
      Weaves DoubleStream.min(), as doubleStreamSum(java.util.stream.DoubleStream).
      Parameters:
      receiver - the stream
      Returns:
      the least, if any element
      Since:
      1.14.2
    • doubleStreamMax

      public static OptionalDouble doubleStreamMax(DoubleStream receiver)
      Weaves DoubleStream.max(), as doubleStreamSum(java.util.stream.DoubleStream).
      Parameters:
      receiver - the stream
      Returns:
      the greatest, if any element
      Since:
      1.14.2
    • doubleStreamSummaryStatistics

      public static DoubleSummaryStatistics doubleStreamSummaryStatistics(DoubleStream receiver)
      Weaves DoubleStream.summaryStatistics(), as doubleStreamSum(java.util.stream.DoubleStream).
      Parameters:
      receiver - the stream
      Returns:
      count, sum, least, greatest and mean
      Since:
      1.14.2
    • doubleStreamToArray

      public static double[] doubleStreamToArray(DoubleStream receiver)
      Weaves DoubleStream.toArray(), as doubleStreamSum(java.util.stream.DoubleStream).
      Parameters:
      receiver - the stream
      Returns:
      the elements
      Since:
      1.14.2
    • doubleStreamFindFirst

      public static OptionalDouble doubleStreamFindFirst(DoubleStream receiver)
      Weaves DoubleStream.findFirst(), as doubleStreamSum(java.util.stream.DoubleStream).
      Parameters:
      receiver - the stream
      Returns:
      the first element, if any
      Since:
      1.14.2
    • doubleStreamFindAny

      public static OptionalDouble doubleStreamFindAny(DoubleStream receiver)
      Weaves DoubleStream.findAny(), as doubleStreamSum(java.util.stream.DoubleStream).
      Parameters:
      receiver - the stream
      Returns:
      some element, if any
      Since:
      1.14.2
    • shutdownNow

      public static List<Runnable> shutdownNow(ExecutorService receiver)
      Weaves ExecutorService.shutdownNow(): what comes back is the tasks execute(java.util.concurrent.Executor, java.lang.Runnable) was given, not the wrappers it queued (#1155), so code that re-queues or inspects them sees its own. A list with no wrapper in it is returned as the executor made it.
      Parameters:
      receiver - the executor the call site invoked
      Returns:
      the tasks that never started
      Since:
      1.14.1
    • awaitTermination

      public static boolean awaitTermination(ExecutorService receiver, long timeout, TimeUnit unit) throws InterruptedException
      Weaves ExecutorService.awaitTermination(long, TimeUnit) (#1266): a true return means every task the pool ran has ended, so the caller is ordered after what each task a woven submit or execute wrapped did; each released into the pool as it ended. A false return orders nothing. See poolTerminated(java.util.concurrent.ExecutorService) for which pools count.
      Parameters:
      receiver - the executor
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      whether the executor terminated
      Throws:
      InterruptedException - if interrupted while waiting
      Since:
      1.14.3
    • closeExecutor

      public static void closeExecutor(ExecutorService receiver)
      Weaves ExecutorService.close() (#1266), the end of a try-with-resources block over an executor: it returns once every task has ended, so the caller is ordered after them as after awaitTermination(java.util.concurrent.ExecutorService, long, java.util.concurrent.TimeUnit). The common pool's close does nothing, which poolTerminated(java.util.concurrent.ExecutorService) sees.
      Parameters:
      receiver - the executor
      Since:
      1.14.3
    • removeFromPool

      public static boolean removeFromPool(ThreadPoolExecutor pool, Runnable task)
      Weaves ThreadPoolExecutor.remove(Runnable): the caller names the task it gave to execute(java.util.concurrent.Executor, java.lang.Runnable), and the queue holds the wrapper around it (#1155).
      Parameters:
      pool - the pool the call site invoked
      task - the task to remove
      Returns:
      whether it was removed
      Since:
      1.14.1
    • poolQueue

      public static BlockingQueue<Runnable> poolQueue(ThreadPoolExecutor pool)
      Weaves ThreadPoolExecutor.getQueue() (#1173): where the pool queues wrappers around the tasks execute(java.util.concurrent.Executor, java.lang.Runnable) was given, woven code reads the queue through a view that holds the caller's own tasks, removes them by those tasks, and tells the schedule a task taken out of it will never run. Anywhere else the pool's own queue is returned, so its identity is unchanged outside a run.
      Parameters:
      pool - the pool the call site invoked
      Returns:
      the pool's queue, or a view of it that unwraps the tasks
      Since:
      1.14.3
    • poolTask

      public static Runnable poolTask(Runnable task)
      Returns the task the caller gave, where task is the wrapper execute(java.util.concurrent.Executor, java.lang.Runnable) queued around it, or task itself. The agent inserts this at the entry of a ThreadPoolExecutor subclass's beforeExecute and afterExecute, and of a RejectedExecutionHandler's rejectedExecution, storing the result back into the parameter, so the override is handed what the caller gave (#1173). Not a schedule point: the pool, not the caller, calls these.
      Parameters:
      task - the task the pool handed the method
      Returns:
      the task the caller gave, where task is the wrapper execute(java.util.concurrent.Executor, java.lang.Runnable) queued around it, or task itself
      Since:
      1.14.3
    • poolTaskOverrideWoven

      public static void poolTaskOverrideWoven(String className)
      Records that the agent rewrote className's beforeExecute, afterExecute or rejectedExecution with poolTask(java.lang.Runnable) (#1173), so execute(java.util.concurrent.Executor, java.lang.Runnable) may wrap a task for a pool that overrides them or uses that handler. Called by the agent while it weaves the class, before the class can be used; a class it never reports keeps its pool's tasks unwrapped, the direction that cannot report correct code.
      Parameters:
      className - the binary name of the rewritten class
      Since:
      1.14.3
    • invokeAll

      public static List<Future<Object>> invokeAll(ExecutorService receiver, Collection<? extends Callable<Object>> tasks) throws InterruptedException
      Weaves ExecutorService.invokeAll(Collection). A task of this pool that calls it waits for tasks of its own pool, as a get on one does (#1175).
      Parameters:
      receiver - the executor
      tasks - the tasks to run and wait for
      Returns:
      their futures
      Throws:
      InterruptedException - if interrupted while waiting
      Since:
      1.14.1
    • invokeAny

      public static @Nullable Object invokeAny(ExecutorService receiver, Collection<? extends Callable<Object>> tasks) throws InterruptedException, ExecutionException
      Weaves ExecutorService.invokeAny(Collection), as invokeAll(ExecutorService, Collection).
      Parameters:
      receiver - the executor
      tasks - the tasks to run, one of which must finish
      Returns:
      the result of one that did
      Throws:
      InterruptedException - if interrupted while waiting
      ExecutionException - if none finished normally
      Since:
      1.14.1
    • invokeAny

      public static @Nullable Object invokeAny(ExecutorService receiver, Collection<? extends Callable<Object>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
      Weaves ExecutorService.invokeAny(Collection, long, TimeUnit), as invokeAll(ExecutorService, Collection).
      Parameters:
      receiver - the executor
      tasks - the tasks to run, one of which must finish
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      the result of one that did
      Throws:
      InterruptedException - if interrupted while waiting
      ExecutionException - if none finished normally
      TimeoutException - if the wait timed out
      Since:
      1.14.1
    • invokeAll

      public static List<Future<Object>> invokeAll(ExecutorService receiver, Collection<? extends Callable<Object>> tasks, long timeout, TimeUnit unit) throws InterruptedException
      Weaves ExecutorService.invokeAll(Collection, long, TimeUnit), as invokeAll(ExecutorService, Collection).
      Parameters:
      receiver - the executor
      tasks - the tasks to run and wait for
      timeout - how long to wait
      unit - the unit of timeout
      Returns:
      their futures
      Throws:
      InterruptedException - if interrupted while waiting
      Since:
      1.14.1
    • threadLocalGet

      public static @Nullable Object threadLocalGet(ThreadLocal<?> receiver)
      Weaves ThreadLocal.get(): inside a pooled task the run handed over, the read is recorded on THREAD_LOCAL_LEAKS with the task, so a value an earlier task on the thread set and left behind is told from this task's own (#995).
      Parameters:
      receiver - the thread-local
      Returns:
      what the get returns
      Since:
      1.13.2
    • threadLocalSet

      public static void threadLocalSet(ThreadLocal<?> receiver, @Nullable Object value)
      Weaves ThreadLocal.set(Object), as threadLocalGet(java.lang.ThreadLocal<?>): inside a pooled task the set is recorded with the task (#995).
      Parameters:
      receiver - the thread-local
      value - the value to set
      Since:
      1.13.2
    • threadLocalRemove

      public static void threadLocalRemove(ThreadLocal<?> receiver)
      Weaves ThreadLocal.remove(): the next task on this thread starts clean (#995).
      Parameters:
      receiver - the thread-local
      Since:
      1.13.2
    • atomicRead

      public static void atomicRead(Object atomic)
      A woven read of an AtomicInteger or AtomicLong (#1157).
      Parameters:
      atomic - the atomic the call site read
    • atomicStored

      public static void atomicStored(Object atomic)
      A woven plain store to one of those atomics (#1157).
      Parameters:
      atomic - the atomic the call site wrote
    • atomicIncremented

      public static void atomicIncremented(Object atomic)
      A woven arithmetic update of one of those atomics, the act half of a check-then-act when this thread read the atomic just before (#1249).
      Parameters:
      atomic - the atomic the call site updated
    • updaterRead

      public static void updaterRead(Object receiver, @Nullable String field)
      A woven read of a field through an updater, atomicRead(java.lang.Object) for a slot that is not an object of its own (#1275): tracked by the field's key, so every updater and every call reaching the same field of the same object meet.
      Parameters:
      receiver - the object whose field was read
      field - the field, declaringClass.name; null or empty when the updater could not say, which records nothing
    • updaterIncremented

      public static void updaterIncremented(Object receiver, @Nullable String field)
      A woven arithmetic update of a field through an updater, atomicIncremented(java.lang.Object) for a slot that is not an object of its own (#1275).
      Parameters:
      receiver - the object whose field was updated
      field - the field, as updaterRead(java.lang.Object, java.lang.String) takes it
    • updaterSwapped

      public static void updaterSwapped(Object receiver, @Nullable String field)
      A woven atomic swap of a field through an updater, which ends a pending read, as atomicSwapped(java.lang.Object) does for an atomic (#1275).
      Parameters:
      receiver - the object whose field was swapped
      field - the field, as updaterRead(java.lang.Object, java.lang.String) takes it
    • updaterStored

      public static void updaterStored(Object receiver, @Nullable String field)
      A woven plain store to a field through an updater, as atomicStored(java.lang.Object) records one to an atomic (#1275).
      Parameters:
      receiver - the object whose field was written
      field - the field, as updaterRead(java.lang.Object, java.lang.String) takes it
    • atomicReferenceStored

      public static void atomicReferenceStored(Object reference, @Nullable Object stored)
      A woven store to an AtomicReference (#1174). Only a stored object can have been built from the read, so an enum or a Boolean, which is a status, or null, ends the read instead.
      Parameters:
      reference - the reference the call site wrote
      stored - what it stored
    • atomicSwapped

      public static void atomicSwapped(Object atomic)
      A woven atomic update of one of those atomics, which needs no read before it (#1157).
      Parameters:
      atomic - the atomic the call site updated