APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.utils.async

public Class AsyncExecutor

extends Object
implements Disposable
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.utils.Disposable
Imports
java.util.concurrent.Callable, .ExecutorService, .Executors, .ThreadFactory, .TimeUnit, com.badlogic.gdx.utils.Disposable, .GdxRuntimeException

Allows asynchronous execution of AsyncTask instances on a separate thread. Needs to be disposed via a call to dispose() when no longer used, in which case the executor waits for running tasks to finish. Scheduled but not yet running tasks will not be executed.
Author
badlogic

Field Summary

Modifier and TypeField and Description
private final ExecutorService

Constructor Summary

AccessConstructor and Description
public
AsyncExecutor(int maxConcurrent)

Creates a new AsyncExecutor with the name "AsyncExecutor-Thread".

public
AsyncExecutor(int maxConcurrent, final String
The name of the threads.
name
)

Creates a new AsynchExecutor that allows maxConcurrent Runnable instances to run in parallel.

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Waits for running AsyncTask instances to finish, then destroys any resources like threads.

public <T> AsyncResult<T>
submit(final AsyncTask<T>
the task to execute asynchronously
task
)

Submits a Runnable to be executed asynchronously.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executorback to summary
private final ExecutorService executor

Constructor Detail

AsyncExecutorback to summary
public AsyncExecutor(int maxConcurrent)

Creates a new AsyncExecutor with the name "AsyncExecutor-Thread".

AsyncExecutorback to summary
public AsyncExecutor(int maxConcurrent, final String name)

Creates a new AsynchExecutor that allows maxConcurrent Runnable instances to run in parallel.

Parameters
name:String

The name of the threads.

Method Detail

disposeback to summary
public void dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Waits for running AsyncTask instances to finish, then destroys any resources like threads. Can not be used after this method is called.

Annotations
@Override
submitback to summary
public <T> AsyncResult<T> submit(final AsyncTask<T> task)

Submits a Runnable to be executed asynchronously. If maxConcurrent runnables are already running, the runnable will be queued.

Parameters
task:AsyncTask<T>

the task to execute asynchronously