-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: use FlowSched for worldgen scheduling
Doesn't build artifacts but devlaunch works
- Loading branch information
Showing
16 changed files
with
134 additions
and
469 deletions.
There are no files selected for viewing
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
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,3 @@ | ||
[submodule "FlowSched"] | ||
path = FlowSched | ||
url = https://github.com/RelativityMC/FlowSched.git |
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
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
6 changes: 6 additions & 0 deletions
6
c2me-base/src/main/java/com/ishland/c2me/base/common/scheduler/LockTokenImpl.java
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,6 @@ | ||
package com.ishland.c2me.base.common.scheduler; | ||
|
||
import com.ishland.flowsched.executor.LockToken; | ||
|
||
public record LockTokenImpl(int ownerTag, long pos) implements LockToken { | ||
} |
53 changes: 0 additions & 53 deletions
53
c2me-base/src/main/java/com/ishland/c2me/base/common/scheduler/NeighborLockingManager.java
This file was deleted.
Oops, something went wrong.
88 changes: 0 additions & 88 deletions
88
c2me-base/src/main/java/com/ishland/c2me/base/common/scheduler/NeighborLockingTask.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
c2me-base/src/main/java/com/ishland/c2me/base/common/scheduler/PriorityUtils.java
This file was deleted.
Oops, something went wrong.
57 changes: 52 additions & 5 deletions
57
c2me-base/src/main/java/com/ishland/c2me/base/common/scheduler/ScheduledTask.java
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 |
---|---|---|
@@ -1,13 +1,60 @@ | ||
package com.ishland.c2me.base.common.scheduler; | ||
|
||
public interface ScheduledTask { | ||
import com.ishland.flowsched.executor.LockToken; | ||
import com.ishland.flowsched.executor.Task; | ||
|
||
public boolean tryPrepare(); | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Supplier; | ||
|
||
public void runTask(Runnable postAction); | ||
public class ScheduledTask<T> implements Task { | ||
|
||
public long centerPos(); | ||
private final long pos; | ||
private final Supplier<CompletableFuture<T>> action; | ||
private final LockToken[] lockTokens; | ||
private final CompletableFuture<T> future = new CompletableFuture<>(); | ||
private int priority = Integer.MAX_VALUE; | ||
|
||
public boolean isAsync(); | ||
public ScheduledTask(long pos, Supplier<CompletableFuture<T>> action, LockToken[] lockTokens) { | ||
this.pos = pos; | ||
this.action = action; | ||
this.lockTokens = lockTokens; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
action.get().whenComplete((t, throwable) -> { | ||
if (throwable != null) { | ||
future.completeExceptionally(throwable); | ||
} else { | ||
future.complete(t); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void propagateException(Throwable t) { | ||
future.completeExceptionally(t); | ||
} | ||
|
||
@Override | ||
public LockToken[] lockTokens() { | ||
return this.lockTokens; | ||
} | ||
|
||
@Override | ||
public int priority() { | ||
return this.priority; | ||
} | ||
|
||
public void setPriority(int priority) { | ||
this.priority = priority; | ||
} | ||
|
||
public long getPos() { | ||
return this.pos; | ||
} | ||
|
||
public CompletableFuture<T> getFuture() { | ||
return this.future; | ||
} | ||
} |
Oops, something went wrong.