Skip to content

Commit

Permalink
Small style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Jun 21, 2022
1 parent 44ab9a6 commit 9efd3cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

@DefaultQualifier(NonNull.class)
public abstract class MapWorldInternal implements MapWorld {
private static final int IMAGE_IO_MAX_TASKS = 100;
private static final String DIRTY_CHUNKS_FILE_NAME = "dirty_chunks.json";
private static final String RENDER_PROGRESS_FILE_NAME = "resume_render.json";
private static final Gson GSON = new GsonBuilder()
Expand All @@ -70,7 +71,6 @@ public abstract class MapWorldInternal implements MapWorld {
private final ExecutorService imageIOexecutor;
private final AtomicLong imageIOExecutorSubmittedTasks = new AtomicLong();
private final AtomicLong imageIOExecutorExecutedTasks = new AtomicLong();
private static final int IMAGEIO_MAX_TASKS = 100;
private final ScheduledExecutorService executor;
private final Set<ChunkCoordinate> modifiedChunks = ConcurrentHashMap.newKeySet();
private final BlockColors blockColors;
Expand Down Expand Up @@ -183,14 +183,14 @@ public void saveImage(final Image image) {
try {
image.save();
} finally {
MapWorldInternal.this.imageIOExecutorExecutedTasks.getAndIncrement();
this.imageIOExecutorExecutedTasks.getAndIncrement();
}
});

long executed = this.imageIOExecutorExecutedTasks.get();
long submitted = this.imageIOExecutorSubmittedTasks.get();
for (int failures = 1; (submitted - executed) >= IMAGEIO_MAX_TASKS; ++failures) {
boolean interrupted = Thread.interrupted();
for (int failures = 1; (submitted - executed) >= IMAGE_IO_MAX_TASKS; ++failures) {
final boolean interrupted = Thread.interrupted();
Thread.yield();
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(Math.min(25, failures)));
if (interrupted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport;
import java.util.function.BooleanSupplier;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -492,7 +491,8 @@ private static int applyDepthCheckerboard(final double fluidCountY, final int co
}
try {
future.get(Math.min(50, failures), TimeUnit.MILLISECONDS);
} catch (InterruptedException | TimeoutException | ExecutionException ignore) {}
} catch (final InterruptedException | TimeoutException | ExecutionException ignore) {
}
}
return future.join();
}
Expand Down

0 comments on commit 9efd3cd

Please sign in to comment.