async pathfinding: fix path race condition#620
Open
hayanesuru wants to merge 1 commit intoWinds-Studio:ver/1.21.11from
Open
async pathfinding: fix path race condition#620hayanesuru wants to merge 1 commit intoWinds-Studio:ver/1.21.11from
hayanesuru wants to merge 1 commit intoWinds-Studio:ver/1.21.11from
Conversation
c646459 to
f317d41
Compare
MartijnMuijsers
requested changes
Feb 20, 2026
| * ConcurrentLinkedQueue is thread-safe, non-blocking and non-synchronized | ||
| */ | ||
| private final ConcurrentLinkedQueue<Runnable> postProcessing = new ConcurrentLinkedQueue<>(); | ||
| private final ArrayList<Consumer<Path>> postProcessing = new ArrayList<>(); |
Collaborator
There was a problem hiding this comment.
I'm assuming schedulePostProcessing is only called from the main thread, correct? Otherwise the .add will cause issues when called from multiple threads
leaf-server/src/main/java/org/dreeam/leaf/async/path/AsyncPath.java
Outdated
Show resolved
Hide resolved
| if (!ready) { | ||
| Path ret = this.ret; | ||
| if (ret != null) { | ||
| complete(ret); |
Collaborator
There was a problem hiding this comment.
If this path is only completed upon isDone, what happens upon isProcessed? Shoud it also call complete?
I assume isDone() and isProcessed() can only be run from the main thread, right?
| } | ||
|
|
||
| return this.positions.containsAll(positions); | ||
| return this.positions.equals(positions); |
Collaborator
There was a problem hiding this comment.
Original is containsAll, this changes actual behavior
MartijnMuijsers
approved these changes
Feb 22, 2026
| @@ -67,7 +67,7 @@ protected static CompletableFuture<Void> queue(AsyncPath path) { | |||
| */ | |||
| public static void awaitProcessing(@Nullable Path path, Consumer<@Nullable Path> afterProcessing) { | |||
Collaborator
There was a problem hiding this comment.
This already existed in the original, but the name await here is not really correct. applyAfterProcessing?
leaf-server/src/main/java/org/dreeam/leaf/async/path/AsyncPath.java
Outdated
Show resolved
Hide resolved
leaf-server/src/main/java/org/dreeam/leaf/async/path/AsyncPath.java
Outdated
Show resolved
Hide resolved
f317d41 to
888385d
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#519 #589
Closed #604