-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow cancellation on unloading stage 3
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
patches/main/0010-fix-allow-cancellation-on-unloading-stage-3.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: ishland <[email protected]> | ||
Date: Wed, 25 Dec 2024 22:56:35 +0800 | ||
Subject: [PATCH] fix: allow cancellation on unloading stage 3 | ||
|
||
|
||
diff --git a/c2me-rewrites-chunk-system/src/main/java/com/ishland/c2me/rewrites/chunksystem/common/statuses/ReadFromDiskAsync.java b/c2me-rewrites-chunk-system/src/main/java/com/ishland/c2me/rewrites/chunksystem/common/statuses/ReadFromDiskAsync.java | ||
index 47229eb6..851dab8d 100644 | ||
--- a/c2me-rewrites-chunk-system/src/main/java/com/ishland/c2me/rewrites/chunksystem/common/statuses/ReadFromDiskAsync.java | ||
+++ b/c2me-rewrites-chunk-system/src/main/java/com/ishland/c2me/rewrites/chunksystem/common/statuses/ReadFromDiskAsync.java | ||
@@ -159,10 +159,6 @@ public class ReadFromDiskAsync extends ReadFromDisk { | ||
worldChunk.setLoadedToWorld(false); | ||
} | ||
|
||
- if (loadedToWorld.get() && chunk instanceof WorldChunk worldChunk) { | ||
- LifecycleEventInvoker.invokeChunkUnload(((IThreadedAnvilChunkStorage) context.tacs()).getWorld(), worldChunk); | ||
- } | ||
- | ||
if ((context.holder().getFlags() & ItemHolder.FLAG_BROKEN) != 0 && chunk instanceof ProtoChunk) { // do not save broken ProtoChunks | ||
LOGGER.warn("Not saving partially generated broken chunk {}", context.holder().getKey()); | ||
return CompletableFuture.completedStage((Void) null); | ||
@@ -180,7 +176,17 @@ public class ReadFromDiskAsync extends ReadFromDisk { | ||
try (var ignored = ThreadInstrumentation.getCurrent().begin(new ChunkTaskWork(context, this, false))) { | ||
Chunk chunk = context.holder().getItem().get().chunk(); | ||
if (chunk instanceof WrapperProtoChunk protoChunk) chunk = protoChunk.getWrappedChunk(); | ||
+ | ||
+ if (context.holder().getTargetStatus().ordinal() >= this.ordinal()) { // saving cancelled late | ||
+ if (chunk instanceof WorldChunk worldChunk) { | ||
+ worldChunk.setLoadedToWorld(loadedToWorld.get()); | ||
+ } | ||
+ cancellable.cancel(); | ||
+ throw new CancellationException(); | ||
+ } | ||
+ | ||
if (loadedToWorld.get() && chunk instanceof WorldChunk worldChunk) { | ||
+ LifecycleEventInvoker.invokeChunkUnload(((IThreadedAnvilChunkStorage) context.tacs()).getWorld(), worldChunk); | ||
((IThreadedAnvilChunkStorage) context.tacs()).getWorld().unloadEntities(worldChunk); | ||
} | ||
|