enhancement #I7XAIB 调整 When 任务命名

This commit is contained in:
luoyi
2023-09-18 20:58:25 +08:00
parent 23f53dceb5
commit d7c6383b09
3 changed files with 10 additions and 10 deletions

View File

@@ -18,13 +18,13 @@ public class AllOfParallelExecutor extends ParallelStrategyExecutor {
public void execute(WhenCondition whenCondition, Integer slotIndex) throws Exception {
// 获取所有 CompletableFuture 任务
List<CompletableFuture<WhenFutureObj>> allTaskList = this.getAllTaskList(whenCondition, slotIndex);
List<CompletableFuture<WhenFutureObj>> whenAllTaskList = this.getWhenAllTaskList(whenCondition, slotIndex);
// 把这些 CompletableFuture 通过 allOf 合成一个 CompletableFuture表明完成所有任务
CompletableFuture<?> specifyTask = CompletableFuture.allOf(allTaskList.toArray(new CompletableFuture[] {}));
CompletableFuture<?> specifyTask = CompletableFuture.allOf(whenAllTaskList.toArray(new CompletableFuture[] {}));
// 结果处理
this.handleTaskResult(whenCondition, slotIndex, allTaskList, specifyTask);
this.handleTaskResult(whenCondition, slotIndex, whenAllTaskList, specifyTask);
}

View File

@@ -18,13 +18,13 @@ public class AnyOfParallelExecutor extends ParallelStrategyExecutor {
public void execute(WhenCondition whenCondition, Integer slotIndex) throws Exception {
// 获取所有 CompletableFuture 任务
List<CompletableFuture<WhenFutureObj>> allTaskList = this.getAllTaskList(whenCondition, slotIndex);
List<CompletableFuture<WhenFutureObj>> whenAllTaskList = this.getWhenAllTaskList(whenCondition, slotIndex);
// 把这些 CompletableFuture 通过 anyOf 合成一个 CompletableFuture表明完成任一任务
CompletableFuture<?> specifyTask = CompletableFuture.anyOf(allTaskList.toArray(new CompletableFuture[] {}));
CompletableFuture<?> specifyTask = CompletableFuture.anyOf(whenAllTaskList.toArray(new CompletableFuture[] {}));
// 结果处理
this.handleTaskResult(whenCondition, slotIndex, allTaskList, specifyTask);
this.handleTaskResult(whenCondition, slotIndex, whenAllTaskList, specifyTask);
}

View File

@@ -86,7 +86,7 @@ public abstract class ParallelStrategyExecutor {
* @param slotIndex
* @return
*/
protected List<CompletableFuture<WhenFutureObj>> getAllTaskList(WhenCondition whenCondition, Integer slotIndex) {
protected List<CompletableFuture<WhenFutureObj>> getWhenAllTaskList(WhenCondition whenCondition, Integer slotIndex) {
String currChainName = whenCondition.getCurrChainId();
@@ -121,11 +121,11 @@ public abstract class ParallelStrategyExecutor {
* 任务结果处理
* @param whenCondition 并行组件对象
* @param slotIndex 当前 slot 的 index
* @param allTaskList 并行组件中所有任务列表
* @param whenAllTaskList 并行组件中所有任务列表
* @param specifyTask 指定预先完成的任务,详见 {@link ParallelStrategyEnum}
* @throws Exception
*/
protected void handleTaskResult(WhenCondition whenCondition, Integer slotIndex, List<CompletableFuture<WhenFutureObj>> allTaskList,
protected void handleTaskResult(WhenCondition whenCondition, Integer slotIndex, List<CompletableFuture<WhenFutureObj>> whenAllTaskList,
CompletableFuture<?> specifyTask) throws Exception {
Slot slot = DataBus.getSlot(slotIndex);
@@ -147,7 +147,7 @@ public abstract class ParallelStrategyExecutor {
// 如果 any 为 true那么这里拿到的是第一个完成的任务
// 如果为 must那么这里获取到的就是指定的任务
// 这里过滤和转换一起用 lambda 做了
List<WhenFutureObj> allCompletableWhenFutureObjList = allTaskList.stream().filter(f -> {
List<WhenFutureObj> allCompletableWhenFutureObjList = whenAllTaskList.stream().filter(f -> {
// 过滤出已经完成的,没完成的就直接终止
if (f.isDone()) {
return true;