net.minecraftforge.common.util

## Class AsynchronousExecutor<P,T,C,E extends java.lang.Throwable>

- java.lang.Object
- - net.minecraftforge.common.util.AsynchronousExecutor<P,T,C,E>

- Type Parameters:
    `P` - The type of parameter you provide to make the object that will be created. It should implement `Object.hashCode()` and `Object.equals(Object)` if you want to get the value early.
    `T` - The type of object you provide. This is created in stage 1, and passed to stage 2, 3, and returned if get() is called.
    `C` - The type of callback you provide. You may register many of these to be passed to the provider in stage 3, one at a time.
    `E` - A type of exception you may throw and expect to be handled by the main thread

      public final class AsynchronousExecutor<P,T,C,E extends java.lang.Throwable>
      extends java.lang.Object

  Executes tasks using a multi-stage process executor. Synchronous executions are via `finishActive()` or the `get(Object)` methods.
- Stage 1 creates the object from a parameter, and is usually called asynchronously.
- Stage 2 takes the parameter and object from stage 1 and does any synchronous processing to prepare it.
- Stage 3 takes the parameter and object from stage 1, as well as a callback that was registered, and performs any synchronous calculations.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `AsynchronousExecutor.CallBackProvider<P,T,C,E extends java.lang.Throwable>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AsynchronousExecutor(AsynchronousExecutor.CallBackProvider<P,T,C,E> provider, int coreSize)` Uses a thread pool to pass executions to the provider.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(P parameter, C callback)` Adds a callback to the parameter provided, adding parameter to the queue if needed.
    `boolean` | `drop(P parameter, C callback)` This removes a particular callback from the specified parameter.
    `void` | `finishActive()` This is the 'heartbeat' that should be called synchronously to finish any pending tasks
    `T` | `get(P parameter)` This method attempts to skip the waiting period for said parameter.
    `T` | `getSkipQueue(P parameter)` Processes a parameter as if it was in the queue, without ever passing to another thread.
    `T` | `getSkipQueue(P parameter, C... callbacks)` Processes a parameter as if it was in the queue, without ever passing to another thread.
    `T` | `getSkipQueue(P parameter, C callback)` Processes a parameter as if it was in the queue, without ever passing to another thread.
    `T` | `getSkipQueue(P parameter, java.lang.Iterable<C> callbacks)` Processes a parameter as if it was in the queue, without ever passing to another thread.
    `void` | `setActiveThreads(int coreSize)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AsynchronousExecutor

          public AsynchronousExecutor(AsynchronousExecutor.CallBackProvider<P,T,C,E> provider,
                              int coreSize)

      Uses a thread pool to pass executions to the provider.
      See Also:
        `AsynchronousExecutor`

  - ### Method Detail

    - #### add

          public void add(P parameter,
                 C callback)

      Adds a callback to the parameter provided, adding parameter to the queue if needed.

      This should always be synchronous.

    - #### drop

          public boolean drop(P parameter,
                     C callback)
                       throws java.lang.IllegalStateException

      This removes a particular callback from the specified parameter.

      If no callbacks remain for a given parameter, then the `CallBackProvider's` stages may be omitted from execution. Stage 3 will have no callbacks, stage 2 will be skipped unless a `get(Object)` is used, and stage 1 will be avoided on a best-effort basis.

      Subsequent calls to `getSkipQueue(Object)` will always work.

      Subsequent calls to `get(Object)` might work.

      This should always be synchronous

      Returns:
        true if no further execution for the parameter is possible, such that, no exceptions will be thrown in `finishActive()` for the parameter, and `get(Object)` will throw an `IllegalStateException`, false otherwise
      Throws:
        `java.lang.IllegalStateException` - if parameter is not in the queue anymore
        `java.lang.IllegalStateException` - if the callback was not specified for given parameter

    - #### get

          public T get(P parameter)
                throws E extends java.lang.Throwable,
                       java.lang.IllegalStateException

      This method attempts to skip the waiting period for said parameter.

      This should always be synchronous.

      Throws:
        `java.lang.IllegalStateException` - if the parameter is not in the queue anymore, or sometimes if called from asynchronous thread
        `E extends java.lang.Throwable`

    - #### getSkipQueue

          public T getSkipQueue(P parameter)
                         throws E extends java.lang.Throwable

      Processes a parameter as if it was in the queue, without ever passing to another thread.
      Throws:
        `E extends java.lang.Throwable`

    - #### getSkipQueue

          public T getSkipQueue(P parameter,
                       C callback)
                         throws E extends java.lang.Throwable

      Processes a parameter as if it was in the queue, without ever passing to another thread.
      Throws:
        `E extends java.lang.Throwable`

    - #### getSkipQueue

          public T getSkipQueue(P parameter,
                       C... callbacks)
                         throws E extends java.lang.Throwable

      Processes a parameter as if it was in the queue, without ever passing to another thread.
      Throws:
        `E extends java.lang.Throwable`

    - #### getSkipQueue

          public T getSkipQueue(P parameter,
                       java.lang.Iterable<C> callbacks)
                         throws E extends java.lang.Throwable

      Processes a parameter as if it was in the queue, without ever passing to another thread.
      Throws:
        `E extends java.lang.Throwable`

    - #### finishActive

          public void finishActive()
                            throws E extends java.lang.Throwable

      This is the 'heartbeat' that should be called synchronously to finish any pending tasks
      Throws:
        `E extends java.lang.Throwable`

    - #### setActiveThreads

          public void setActiveThreads(int coreSize)