Permalink
Browse files

Use UUID rather than Actor for nicer hashing of TaskManager

  • Loading branch information...
me4502 committed Aug 29, 2018
1 parent 56aa68a commit ad83474368ab00897282991dd32528e4137e83fe
Showing with 5 additions and 4 deletions.
  1. +5 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/task/TaskManager.java
@@ -24,11 +24,12 @@
import com.sk89q.worldedit.function.operation.RunContext;
import java.util.Map;
import java.util.UUID;
import java.util.WeakHashMap;
public class TaskManager {
private final Map<Actor, TaskQueue> taskQueues = new WeakHashMap<>();
private final Map<UUID, TaskQueue> taskQueues = new WeakHashMap<>();
public TaskManager() {
}
@@ -39,15 +40,15 @@ public TaskManager() {
* @param actor The actor
*/
public TaskQueue getTaskQueue(Actor actor) {
return taskQueues.computeIfAbsent(actor, x -> new TaskQueue());
return taskQueues.computeIfAbsent(actor.getUniqueId(), x -> new TaskQueue());
}
/**
* Tick all of the task queues
*/
public void tickTaskQueues() {
for (Map.Entry<Actor, TaskQueue> queueEntry : taskQueues.entrySet()) {
queueEntry.getValue().resume(new RunContext());
for (TaskQueue queue : taskQueues.values()) {
queue.resume(new RunContext());
}
}
}

0 comments on commit ad83474

Please sign in to comment.