mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Ensure forceSync is provided when constructing chunk coordinators
This commit is contained in:
parent
0a32268784
commit
a46037b1f1
@ -92,9 +92,9 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator {
|
|||||||
@Assisted final @NonNull Collection<BlockVector2> requestedChunks,
|
@Assisted final @NonNull Collection<BlockVector2> requestedChunks,
|
||||||
@Assisted final @NonNull Runnable whenDone,
|
@Assisted final @NonNull Runnable whenDone,
|
||||||
@Assisted final @NonNull Consumer<Throwable> throwableConsumer,
|
@Assisted final @NonNull Consumer<Throwable> throwableConsumer,
|
||||||
@Assisted final boolean unloadAfter,
|
@Assisted("unloadAfter") final boolean unloadAfter,
|
||||||
@Assisted final @NonNull Collection<ProgressSubscriber> progressSubscribers,
|
@Assisted final @NonNull Collection<ProgressSubscriber> progressSubscribers,
|
||||||
@Assisted final boolean forceSync
|
@Assisted("forceSync") final boolean forceSync
|
||||||
) {
|
) {
|
||||||
this.requestedChunks = new LinkedBlockingQueue<>(requestedChunks);
|
this.requestedChunks = new LinkedBlockingQueue<>(requestedChunks);
|
||||||
this.availableChunks = new LinkedBlockingQueue<>();
|
this.availableChunks = new LinkedBlockingQueue<>();
|
||||||
|
@ -235,6 +235,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
|||||||
.withConsumer(consumer)
|
.withConsumer(consumer)
|
||||||
.unloadAfter(isUnloadAfter())
|
.unloadAfter(isUnloadAfter())
|
||||||
.withProgressSubscribers(getProgressSubscribers())
|
.withProgressSubscribers(getProgressSubscribers())
|
||||||
|
.forceSync(isForceSync())
|
||||||
.build();
|
.build();
|
||||||
return super.enqueue();
|
return super.enqueue();
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.inject.factory;
|
package com.plotsquared.core.inject.factory;
|
||||||
|
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.plotsquared.core.queue.ChunkCoordinator;
|
import com.plotsquared.core.queue.ChunkCoordinator;
|
||||||
import com.plotsquared.core.queue.subscriber.ProgressSubscriber;
|
import com.plotsquared.core.queue.subscriber.ProgressSubscriber;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -44,8 +45,9 @@ public interface ChunkCoordinatorFactory {
|
|||||||
final @NonNull Collection<BlockVector2> requestedChunks,
|
final @NonNull Collection<BlockVector2> requestedChunks,
|
||||||
final @NonNull Runnable whenDone,
|
final @NonNull Runnable whenDone,
|
||||||
final @NonNull Consumer<Throwable> throwableConsumer,
|
final @NonNull Consumer<Throwable> throwableConsumer,
|
||||||
final boolean unloadAfter,
|
@Assisted("unloadAfter") final boolean unloadAfter,
|
||||||
final @NonNull Collection<ProgressSubscriber> progressSubscribers
|
final @NonNull Collection<ProgressSubscriber> progressSubscribers,
|
||||||
|
@Assisted("forceSync") final boolean forceSync
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ public class ChunkCoordinatorBuilder {
|
|||||||
private long maxIterationTime = Settings.QUEUE.MAX_ITERATION_TIME; // A little over 1 tick;
|
private long maxIterationTime = Settings.QUEUE.MAX_ITERATION_TIME; // A little over 1 tick;
|
||||||
private int initialBatchSize = Settings.QUEUE.INITIAL_BATCH_SIZE;
|
private int initialBatchSize = Settings.QUEUE.INITIAL_BATCH_SIZE;
|
||||||
private boolean unloadAfter = true;
|
private boolean unloadAfter = true;
|
||||||
|
private boolean forceSync = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ChunkCoordinatorBuilder(@NonNull ChunkCoordinatorFactory chunkCoordinatorFactory) {
|
public ChunkCoordinatorBuilder(@NonNull ChunkCoordinatorFactory chunkCoordinatorFactory) {
|
||||||
@ -197,6 +198,18 @@ public class ChunkCoordinatorBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the chunks coordinator should be forced to be synchronous. This is not necessarily synchronous to the server,
|
||||||
|
* and simply effectively makes {@link ChunkCoordinator#start()} ()} a blocking operation.
|
||||||
|
*
|
||||||
|
* @param forceSync force sync or not
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public @NonNull ChunkCoordinatorBuilder forceSync(final boolean forceSync) {
|
||||||
|
this.forceSync = forceSync;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public @NonNull ChunkCoordinatorBuilder withProgressSubscriber(ProgressSubscriber progressSubscriber) {
|
public @NonNull ChunkCoordinatorBuilder withProgressSubscriber(ProgressSubscriber progressSubscriber) {
|
||||||
this.progressSubscribers.add(progressSubscriber);
|
this.progressSubscribers.add(progressSubscriber);
|
||||||
return this;
|
return this;
|
||||||
@ -227,7 +240,8 @@ public class ChunkCoordinatorBuilder {
|
|||||||
this.whenDone,
|
this.whenDone,
|
||||||
this.throwableConsumer,
|
this.throwableConsumer,
|
||||||
this.unloadAfter,
|
this.unloadAfter,
|
||||||
this.progressSubscribers
|
this.progressSubscribers,
|
||||||
|
this.forceSync
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,14 +40,12 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public abstract class QueueCoordinator {
|
public abstract class QueueCoordinator {
|
||||||
@ -117,7 +115,8 @@ public abstract class QueueCoordinator {
|
|||||||
public abstract void setModified(long modified);
|
public abstract void setModified(long modified);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the queue should be forced to be synchronous when enqueued.
|
* Returns true if the queue should be forced to be synchronous when enqueued. This is not necessarily synchronous to the
|
||||||
|
* server, and simply effectively makes {@link QueueCoordinator#enqueue()} a blocking operation.
|
||||||
*
|
*
|
||||||
* @return is force sync
|
* @return is force sync
|
||||||
*/
|
*/
|
||||||
@ -126,7 +125,8 @@ public abstract class QueueCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether the queue should be forced to be synchronous
|
* Set whether the queue should be forced to be synchronous. This is not necessarily synchronous to the server, and simply
|
||||||
|
* effectively makes {@link QueueCoordinator#enqueue()} a blocking operation.
|
||||||
*
|
*
|
||||||
* @param forceSync force sync or not
|
* @param forceSync force sync or not
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user