Package com.fastasyncworldedit.core.util
Class TaskManager
java.lang.Object
com.fastasyncworldedit.core.util.TaskManager
-
Field Summary
Modifier and TypeFieldDescriptionstatic TaskManager
Deprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Run a task asynchronously.abstract void
cancel
(int task) Cancel a task.Get the public ForkJoinPool.abstract void
Run a task later on the main thread.abstract void
laterAsync
(Runnable runnable, int delay) Run a task later asynchronously.void
notify
(AtomicBoolean running) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated without replacement as unused internally, and poor implementation of what it's designed to do.<T> void
objectTask
(Collection<T> objects, RunnableVal<T> task, Runnable whenDone) Break up a task and run it in fragments of 5ms.
- Each task will run on the main thread.void
parallel
(Collection<Runnable> runables) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated without replacement as unused internally, and poor implementation of what it's designed to do.void
parallel
(Collection<Runnable> runnables, Integer numThreads) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated without replacement as unused internally, and poor implementation of what it's designed to do.abstract int
Run a repeating task on the main thread.abstract int
repeatAsync
(Runnable runnable, int interval) Run a repeating task asynchronously.void
Disable async catching for a specific task.<T> T
sync
(RunnableVal<T> function) Quickly run a task on the main thread, and wait for execution to finish.<T> T
Quickly run a task on the main thread, and wait for execution to finish.<T> T
syncWhenFree
(RunnableVal<T> function) Run a task on the main thread when the TPS is high enough, and wait for execution to finish.<T> T
syncWhenFree
(Supplier<T> supplier) Run a task on the main thread when the TPS is high enough, and wait for execution to finish.abstract void
Run a task on the main thread.static TaskManager
Gets an instance of the TaskManager.void
Run a task on the current thread or asynchronously.void
taskNowAsync
(Runnable runnable) Run a task as soon as possible not on the main thread.void
taskNowMain
(Runnable runnable) Run a task as soon as possible on the main thread.void
taskSoonMain
(Runnable runnable, boolean async) Run a task on the main thread at the next tick or now async.void
taskWhenFree
(Runnable run) void
wait
(AtomicBoolean running, int timeout) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated without replacement as unused internally, and poor implementation of what it's designed to do.
-
Field Details
-
IMP
Deprecated, for removal: This API element is subject to removal in a future version.UsetaskManager()
to get an instance.
-
-
Constructor Details
-
TaskManager
protected TaskManager()
-
-
Method Details
-
taskManager
Gets an instance of the TaskManager.- Returns:
- an instance of the TaskManager
- Since:
- 2.0.0
-
repeat
Run a repeating task on the main thread.- Parameters:
runnable
- the task to runinterval
- in ticks
-
repeatAsync
Run a repeating task asynchronously.- Parameters:
runnable
- the task to runinterval
- in ticks- Returns:
- the task id number
-
async
Run a task asynchronously.- Parameters:
runnable
- the task to run
-
task
Run a task on the main thread.- Parameters:
runnable
- the task to run
-
getPublicForkJoinPool
Get the public ForkJoinPool. - ONLY SUBMIT SHORT LIVED TASKS
- DO NOT USE SLEEP/WAIT/LOCKS IN ANY SUBMITTED TASKS -
parallel
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated without replacement as unused internally, and poor implementation of what it's designed to do.Run a bunch of tasks in parallel using the shared thread pool. -
parallel
@Deprecated(forRemoval=true, since="2.7.0") public void parallel(Collection<Runnable> runnables, @Nullable Integer numThreads) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated without replacement as unused internally, and poor implementation of what it's designed to do.Run a bunch of tasks in parallel.- Parameters:
runnables
- the tasks to runnumThreads
- number of threads (null = config.yml parallel threads)
-
runUnsafe
Disable async catching for a specific task. -
taskNow
Run a task on the current thread or asynchronously. - If it's already the main thread, it will just call run()- Parameters:
runnable
- the task to runasync
- whether the task should run on the main thread
-
taskNowMain
Run a task as soon as possible on the main thread. - Non blocking if not calling from the main thread- Parameters:
runnable
- the task to run
-
taskNowAsync
Run a task as soon as possible not on the main thread.- Parameters:
runnable
- the task to run- See Also:
-
taskSoonMain
Run a task on the main thread at the next tick or now async.- Parameters:
runnable
- the task to run.async
- whether the task should run on the main thread
-
later
Run a task later on the main thread.- Parameters:
runnable
- the task to rundelay
- in ticks
-
laterAsync
Run a task later asynchronously.- Parameters:
runnable
- the task to rundelay
- in ticks
-
cancel
public abstract void cancel(int task) Cancel a task.- Parameters:
task
- the id of the task to cancel
-
objectTask
Break up a task and run it in fragments of 5ms.
- Each task will run on the main thread.- Parameters:
objects
- the list of objects to run the task fortask
- the task to run on each objectwhenDone
- when the object task completes
-
wait
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated without replacement as unused internally, and poor implementation of what it's designed to do. -
notify
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated without replacement as unused internally, and poor implementation of what it's designed to do. -
taskWhenFree
-
syncWhenFree
Run a task on the main thread when the TPS is high enough, and wait for execution to finish. - Useful if you need to access something from the Bukkit API from another thread
- Usually wait time is around 25ms -
syncWhenFree
Run a task on the main thread when the TPS is high enough, and wait for execution to finish. - Useful if you need to access something from the Bukkit API from another thread
- Usually wait time is around 25ms -
sync
Quickly run a task on the main thread, and wait for execution to finish. - Useful if you need to access something from the Bukkit API from another thread
- Usually wait time is around 25ms -
sync
Quickly run a task on the main thread, and wait for execution to finish. - Useful if you need to access something from the Bukkit API from another thread
- Usually wait time is around 25ms
-
taskManager()
to get an instance.