Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public abstract class QueueHandler implements Trimable, Runnable {
/**
* Secondary queue should be used for "cleanup" tasks that are likely to be shorter in life than those submitted to the
* primary queue. They may be IO-bound tasks.
*
* @see #getForkJoinPoolSecondary() the full task contract and the reasoning behind it
*/
private final ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool(
Settings.settings().QUEUE.PARALLEL_THREADS,
Expand Down Expand Up @@ -195,6 +197,11 @@ public <T extends Future<T>> void complete(Future<T> task) {
* Complete a task in the {@code forkJoinPoolSecondary} queue. Secondary queue should be used for "cleanup" tasks that are
* likely to be shorter in life than those submitted to the primary queue. They may be IO-bound tasks.
*
* <p>
* The submitted task must not wait on a {@link Future} completed by this pool, and must not be actor or command work.
* See {@link #getForkJoinPoolSecondary()} for the full contract and the reasoning behind it.
* </p>
Comment on lines +200 to +203

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mm this is probably a good point

Comment on lines +200 to +203
*
* @param run Runnable to run
* @param value Value to return when done
* @param <T> Value type
Expand All @@ -208,6 +215,11 @@ public <T> Future<T> async(Runnable run, T value) {
* Complete a task in the {@code forkJoinPoolSecondary} queue. Secondary queue should be used for "cleanup" tasks that are
* likely to be shorter in life than those submitted to the primary queue. They may be IO-bound tasks.
*
* <p>
* The submitted task must not wait on a {@link Future} completed by this pool, and must not be actor or command work.
* See {@link #getForkJoinPoolSecondary()} for the full contract and the reasoning behind it.
* </p>
*
* @param run Runnable to run
* @return Future for submitted task
*/
Expand All @@ -219,6 +231,11 @@ public Future<?> async(Runnable run) {
* Complete a task in the {@code forkJoinPoolSecondary} queue. Secondary queue should be used for "cleanup" tasks that are
* likely to be shorter in life than those submitted to the primary queue. They may be IO-bound tasks.
*
* <p>
* The submitted task must not wait on a {@link Future} completed by this pool, and must not be actor or command work.
* See {@link #getForkJoinPoolSecondary()} for the full contract and the reasoning behind it.
* </p>
*
* @param call Callable to run
* @param <T> Return value type
* @return Future for submitted task
Expand Down Expand Up @@ -542,6 +559,27 @@ public ExecutorService getForkJoinPoolPrimary() {
/**
* Secondary queue should be used for "cleanup" tasks that are likely to be shorter in life than those submitted to the
* primary queue. They may be IO-bound tasks.
*
* <p>
* Tasks submitted here must observe two rules:
* </p>
* <ul>
* <li><b>A task must not wait on anything this pool completes.</b> {@link ForkJoinPool} only compensates for
* blocking it can observe via {@link ForkJoinPool#managedBlock(ForkJoinPool.ManagedBlocker)}. It cannot see
* {@code monitorenter} or {@link Future#get()}, so it counts a blocked worker as running and does not start a
* replacement. Every worker can therefore end up parked waiting for work that only this pool can perform, and
* nothing progresses. If a task does have such a dependency, do not block inside it: submit the dependent half as
* a separate task and chain the futures.</li>
* <li><b>No actor or command work.</b> Player-facing actions belong on
* {@link com.sk89q.worldedit.extension.platform.Actor#runAction(Runnable, boolean, boolean)} (or its
* {@code queueAction} / {@code runAsyncIfFree} wrappers), which serialises per actor without holding a worker
* here.</li>
* </ul>
* <p>
* Downstream plugins should not submit whole edits or other long-lived work to this pool, and should use their own
* threads instead. The pool is sized by {@code parallel-threads} for FAWE's own cleanup work; occupying it starves
* that work.
* </p>
* <p>
* Internal API usage only.
*
Expand Down
Loading