Skip to content

Commit

Permalink
rename & improve little
Browse files Browse the repository at this point in the history
  • Loading branch information
admin-kowalski committed May 17, 2023
1 parent 76760a9 commit f5374b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import com.ice.core.utils.IceExecutor;
import com.ice.core.utils.IceLinkedList;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.concurrent.Future;

/**
Expand Down Expand Up @@ -52,7 +50,7 @@ protected NodeRunStateEnum processNode(IceContext ctx) {
long nodeId = 0;
try {
while (size > 0) {
List<Pair<Long, Future<NodeRunStateEnum>>> removeFuturePairs = new ArrayList<>(size);
Set<Pair<Long, Future<NodeRunStateEnum>>> doneFuturePairs = new HashSet<>();
for (Pair<Long, Future<NodeRunStateEnum>> pair : futurePairs) {
nodeId = pair.getKey();
Future<NodeRunStateEnum> future = pair.getValue();
Expand All @@ -65,12 +63,12 @@ protected NodeRunStateEnum processNode(IceContext ctx) {
if (!hasTrue) {
hasTrue = stateEnum == NodeRunStateEnum.TRUE;
}
removeFuturePairs.add(pair);
doneFuturePairs.add(pair);
size--;
}
}
if (size > 0) {
for (Pair<Long, Future<NodeRunStateEnum>> pair : removeFuturePairs) {
for (Pair<Long, Future<NodeRunStateEnum>> pair : doneFuturePairs) {
futurePairs.remove(pair);
}
Thread.yield();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import com.ice.core.utils.IceExecutor;
import com.ice.core.utils.IceLinkedList;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.concurrent.Future;

/**
Expand Down Expand Up @@ -52,7 +50,7 @@ protected NodeRunStateEnum processNode(IceContext ctx) {
long nodeId = 0;
try {
while (size > 0) {
List<Pair<Long, Future<NodeRunStateEnum>>> removeFuturePairs = new ArrayList<>(size);
Set<Pair<Long, Future<NodeRunStateEnum>>> doneFuturePairs = new HashSet<>();
for (Pair<Long, Future<NodeRunStateEnum>> pair : futurePairs) {
nodeId = pair.getKey();
Future<NodeRunStateEnum> future = pair.getValue();
Expand All @@ -65,12 +63,12 @@ protected NodeRunStateEnum processNode(IceContext ctx) {
if (!hasFalse) {
hasFalse = stateEnum == NodeRunStateEnum.FALSE;
}
removeFuturePairs.add(pair);
doneFuturePairs.add(pair);
size--;
}
}
if (size > 0) {
for (Pair<Long, Future<NodeRunStateEnum>> pair : removeFuturePairs) {
for (Pair<Long, Future<NodeRunStateEnum>> pair : doneFuturePairs) {
futurePairs.remove(pair);
}
Thread.yield();
Expand Down

0 comments on commit f5374b4

Please sign in to comment.