mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
parent
50ecc5908d
commit
8c5bb96fdd
@ -41,6 +41,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,16 +159,14 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean generate() throws Exception {
|
private boolean generate() throws Exception {
|
||||||
|
ThreadFactory factory = new ThreadFactoryBuilder()
|
||||||
|
.setNameFormat("FAWE Regenerator - %d")
|
||||||
|
.build();
|
||||||
if (generateConcurrent) {
|
if (generateConcurrent) {
|
||||||
//Using concurrent chunk generation
|
//Using concurrent chunk generation
|
||||||
executor = Executors.newFixedThreadPool(Settings.settings().QUEUE.PARALLEL_THREADS, new ThreadFactoryBuilder()
|
executor = Executors.newFixedThreadPool(Settings.settings().QUEUE.PARALLEL_THREADS, factory);
|
||||||
.setNameFormat("fawe-regen-%d")
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
} else { // else using sequential chunk generation, concurrent not supported
|
} else { // else using sequential chunk generation, concurrent not supported
|
||||||
executor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder()
|
executor = Executors.newSingleThreadExecutor(factory);
|
||||||
.setNameFormat("fawe-regen-%d")
|
|
||||||
.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: can we get that required radius down without affecting chunk generation (e.g. strucures, features, ...)?
|
//TODO: can we get that required radius down without affecting chunk generation (e.g. strucures, features, ...)?
|
||||||
|
@ -144,7 +144,7 @@ public class Fawe {
|
|||||||
0L,
|
0L,
|
||||||
TimeUnit.MILLISECONDS,
|
TimeUnit.MILLISECONDS,
|
||||||
new LinkedBlockingQueue<>(),
|
new LinkedBlockingQueue<>(),
|
||||||
new ThreadFactoryBuilder().setNameFormat("fawe-clipboard-%d").build()
|
new ThreadFactoryBuilder().setNameFormat("FAWE Clipboard - %d").build()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import com.fastasyncworldedit.core.util.collection.CleanableThreadLocal;
|
|||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import com.sk89q.jnbt.ByteArrayTag;
|
import com.sk89q.jnbt.ByteArrayTag;
|
||||||
import com.sk89q.jnbt.ByteTag;
|
import com.sk89q.jnbt.ByteTag;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -48,7 +49,6 @@ import java.util.Map.Entry;
|
|||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -616,7 +616,7 @@ public enum FaweCache implements Trimable {
|
|||||||
ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(nThreads, true);
|
ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(nThreads, true);
|
||||||
return new ThreadPoolExecutor(nThreads, nThreads,
|
return new ThreadPoolExecutor(nThreads, nThreads,
|
||||||
0L, TimeUnit.MILLISECONDS, queue,
|
0L, TimeUnit.MILLISECONDS, queue,
|
||||||
Executors.defaultThreadFactory(),
|
new ThreadFactoryBuilder().setNameFormat("FAWE Blocking Executor - %d").build(),
|
||||||
new ThreadPoolExecutor.CallerRunsPolicy()
|
new ThreadPoolExecutor.CallerRunsPolicy()
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -2,19 +2,22 @@ package com.fastasyncworldedit.core.util.task;
|
|||||||
|
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ForkJoinWorkerThread;
|
import java.util.concurrent.ForkJoinWorkerThread;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class FaweForkJoinWorkerThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory {
|
public class FaweForkJoinWorkerThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory {
|
||||||
|
|
||||||
private final String nameFormat;
|
private final String nameFormat;
|
||||||
|
private final AtomicInteger idCounter;
|
||||||
|
|
||||||
public FaweForkJoinWorkerThreadFactory(String nameFormat) {
|
public FaweForkJoinWorkerThreadFactory(String nameFormat) {
|
||||||
this.nameFormat = nameFormat;
|
this.nameFormat = nameFormat;
|
||||||
|
this.idCounter = new AtomicInteger(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
|
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
|
||||||
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
|
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
|
||||||
worker.setName(String.format(nameFormat, worker.getPoolIndex()));
|
worker.setName(String.format(nameFormat, idCounter.getAndIncrement()));
|
||||||
return worker;
|
return worker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user