mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-20 07:02:32 +01:00
Experimental inverse batch option
This commit is contained in:
parent
7fcd4039cb
commit
de51970965
@ -7,6 +7,7 @@ import net.minestom.server.instance.Instance;
|
|||||||
import net.minestom.server.instance.InstanceContainer;
|
import net.minestom.server.instance.InstanceContainer;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -32,6 +33,8 @@ public class AbsoluteBlockBatch implements Batch<Runnable> {
|
|||||||
protected final CountDownLatch readyLatch;
|
protected final CountDownLatch readyLatch;
|
||||||
private final BatchOption options;
|
private final BatchOption options;
|
||||||
|
|
||||||
|
private volatile BatchOption inverseOption = new BatchOption();
|
||||||
|
|
||||||
public AbsoluteBlockBatch() {
|
public AbsoluteBlockBatch() {
|
||||||
this(new BatchOption());
|
this(new BatchOption());
|
||||||
}
|
}
|
||||||
@ -118,7 +121,7 @@ public class AbsoluteBlockBatch implements Batch<Runnable> {
|
|||||||
protected AbsoluteBlockBatch apply(@NotNull Instance instance, @Nullable Runnable callback, boolean safeCallback) {
|
protected AbsoluteBlockBatch apply(@NotNull Instance instance, @Nullable Runnable callback, boolean safeCallback) {
|
||||||
if (!this.options.isUnsafeApply()) this.awaitReady();
|
if (!this.options.isUnsafeApply()) this.awaitReady();
|
||||||
|
|
||||||
final AbsoluteBlockBatch inverse = this.options.shouldCalculateInverse() ? new AbsoluteBlockBatch() : null;
|
final AbsoluteBlockBatch inverse = this.options.shouldCalculateInverse() ? new AbsoluteBlockBatch(inverseOption) : null;
|
||||||
synchronized (chunkBatchesMap) {
|
synchronized (chunkBatchesMap) {
|
||||||
AtomicInteger counter = new AtomicInteger();
|
AtomicInteger counter = new AtomicInteger();
|
||||||
for (Long2ObjectMap.Entry<ChunkBatch> entry : chunkBatchesMap.long2ObjectEntrySet()) {
|
for (Long2ObjectMap.Entry<ChunkBatch> entry : chunkBatchesMap.long2ObjectEntrySet()) {
|
||||||
@ -156,4 +159,14 @@ public class AbsoluteBlockBatch implements Batch<Runnable> {
|
|||||||
|
|
||||||
return inverse;
|
return inverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public @NotNull BatchOption getInverseOption() {
|
||||||
|
return inverseOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public void setInverseOption(@NotNull BatchOption inverseOption) {
|
||||||
|
this.inverseOption = inverseOption;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user