mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-06 15:56:27 +00:00
Cleanup
This commit is contained in:
@@ -29,9 +29,9 @@ import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;
|
||||
import java.util.concurrent.ForkJoinWorkerThread;
|
||||
|
||||
public class GroupedExecutor {
|
||||
private int xc;
|
||||
private final ExecutorService service;
|
||||
private final KMap<String, Integer> mirror;
|
||||
private int xc;
|
||||
|
||||
public GroupedExecutor(int threadLimit, int priority, String name) {
|
||||
xc = 1;
|
||||
|
||||
@@ -38,6 +38,9 @@ import java.util.function.Supplier;
|
||||
@SuppressWarnings("ALL")
|
||||
public class J {
|
||||
private static int tid = 0;
|
||||
private static KList<Runnable> afterStartup = new KList<>();
|
||||
private static KList<Runnable> afterStartupAsync = new KList<>();
|
||||
private static boolean started = false;
|
||||
|
||||
public static void dofor(int a, Function<Integer, Boolean> c, int ch, Consumer<Integer> d) {
|
||||
for (int i = a; c.apply(i); i += ch) {
|
||||
@@ -153,10 +156,6 @@ public class J {
|
||||
}
|
||||
}
|
||||
|
||||
private static KList<Runnable> afterStartup = new KList<>();
|
||||
private static KList<Runnable> afterStartupAsync = new KList<>();
|
||||
private static boolean started = false;
|
||||
|
||||
/**
|
||||
* Dont call this unless you know what you are doing!
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,11 @@ public class PrecisionStopwatch {
|
||||
private double time;
|
||||
private boolean profiling;
|
||||
|
||||
public PrecisionStopwatch() {
|
||||
reset();
|
||||
profiling = false;
|
||||
}
|
||||
|
||||
public static PrecisionStopwatch start() {
|
||||
PrecisionStopwatch p = new PrecisionStopwatch();
|
||||
p.begin();
|
||||
@@ -33,11 +38,6 @@ public class PrecisionStopwatch {
|
||||
return p;
|
||||
}
|
||||
|
||||
public PrecisionStopwatch() {
|
||||
reset();
|
||||
profiling = false;
|
||||
}
|
||||
|
||||
public void begin() {
|
||||
profiling = true;
|
||||
startNano = System.nanoTime();
|
||||
|
||||
@@ -22,6 +22,15 @@ import com.volmit.iris.util.collection.KList;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public interface Queue<T> {
|
||||
static <T> Queue<T> create(KList<T> t) {
|
||||
return new ShurikenQueue<T>().queue(t);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static <T> Queue<T> create(T... t) {
|
||||
return new ShurikenQueue<T>().queue(new KList<T>().add(t));
|
||||
}
|
||||
|
||||
Queue<T> queue(T t);
|
||||
|
||||
Queue<T> queue(KList<T> t);
|
||||
@@ -38,14 +47,5 @@ public interface Queue<T> {
|
||||
|
||||
int size();
|
||||
|
||||
static <T> Queue<T> create(KList<T> t) {
|
||||
return new ShurikenQueue<T>().queue(t);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static <T> Queue<T> create(T... t) {
|
||||
return new ShurikenQueue<T>().queue(new KList<T>().add(t));
|
||||
}
|
||||
|
||||
boolean contains(T p);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;
|
||||
import java.util.concurrent.ForkJoinWorkerThread;
|
||||
|
||||
public class TaskExecutor {
|
||||
private int xc;
|
||||
private final ExecutorService service;
|
||||
private int xc;
|
||||
|
||||
public TaskExecutor(int threadLimit, int priority, String name) {
|
||||
xc = 1;
|
||||
@@ -85,6 +85,13 @@ public class TaskExecutor {
|
||||
service.shutdown();
|
||||
}
|
||||
|
||||
public enum TaskState {
|
||||
QUEUED,
|
||||
RUNNING,
|
||||
COMPLETED,
|
||||
FAILED
|
||||
}
|
||||
|
||||
public static class TaskGroup {
|
||||
private final KList<AssignedTask> tasks;
|
||||
private final TaskExecutor e;
|
||||
@@ -155,34 +162,25 @@ public class TaskExecutor {
|
||||
@SuppressWarnings("ClassCanBeRecord")
|
||||
@ToString
|
||||
public static class TaskResult {
|
||||
public final double timeElapsed;
|
||||
public final int tasksExecuted;
|
||||
public final int tasksFailed;
|
||||
public final int tasksCompleted;
|
||||
public TaskResult(double timeElapsed, int tasksExecuted, int tasksFailed, int tasksCompleted) {
|
||||
this.timeElapsed = timeElapsed;
|
||||
this.tasksExecuted = tasksExecuted;
|
||||
this.tasksFailed = tasksFailed;
|
||||
this.tasksCompleted = tasksCompleted;
|
||||
}
|
||||
|
||||
public final double timeElapsed;
|
||||
public final int tasksExecuted;
|
||||
public final int tasksFailed;
|
||||
public final int tasksCompleted;
|
||||
}
|
||||
|
||||
public enum TaskState {
|
||||
QUEUED,
|
||||
RUNNING,
|
||||
COMPLETED,
|
||||
FAILED
|
||||
}
|
||||
|
||||
public static class AssignedTask {
|
||||
@Getter
|
||||
private final NastyRunnable task;
|
||||
@Getter
|
||||
@Setter
|
||||
private TaskState state;
|
||||
|
||||
@Getter
|
||||
private final NastyRunnable task;
|
||||
|
||||
public AssignedTask(NastyRunnable task) {
|
||||
this.task = task;
|
||||
state = TaskState.QUEUED;
|
||||
|
||||
@@ -30,12 +30,12 @@ import com.volmit.iris.util.math.RollingSequence;
|
||||
*/
|
||||
public class ThreadMonitor extends Thread {
|
||||
private final Thread monitor;
|
||||
private final ChronoLatch cl;
|
||||
private final RollingSequence sq = new RollingSequence(3);
|
||||
int cycles = 0;
|
||||
private boolean running;
|
||||
private State lastState;
|
||||
private final ChronoLatch cl;
|
||||
private PrecisionStopwatch st;
|
||||
int cycles = 0;
|
||||
private final RollingSequence sq = new RollingSequence(3);
|
||||
|
||||
private ThreadMonitor(Thread monitor) {
|
||||
running = true;
|
||||
@@ -46,6 +46,10 @@ public class ThreadMonitor extends Thread {
|
||||
start();
|
||||
}
|
||||
|
||||
public static ThreadMonitor bind(Thread monitor) {
|
||||
return new ThreadMonitor(monitor);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (running) {
|
||||
try {
|
||||
@@ -84,8 +88,4 @@ public class ThreadMonitor extends Thread {
|
||||
public void unbind() {
|
||||
running = false;
|
||||
}
|
||||
|
||||
public static ThreadMonitor bind(Thread monitor) {
|
||||
return new ThreadMonitor(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import com.volmit.iris.util.collection.KList;
|
||||
|
||||
public class JobCollection implements Job {
|
||||
private final String name;
|
||||
private String status;
|
||||
private final KList<Job> jobs;
|
||||
private String status;
|
||||
|
||||
public JobCollection(String name, Job... jobs) {
|
||||
this(name, new KList<>(jobs));
|
||||
|
||||
@@ -24,8 +24,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public abstract class QueueJob<T> implements Job {
|
||||
final KList<T> queue;
|
||||
protected int totalWork;
|
||||
private final AtomicInteger completed;
|
||||
protected int totalWork;
|
||||
|
||||
public QueueJob() {
|
||||
totalWork = 0;
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
package com.volmit.iris.util.scheduling.jobs;
|
||||
|
||||
public class SingleJob implements Job {
|
||||
private boolean done;
|
||||
private final String name;
|
||||
private final Runnable runnable;
|
||||
private boolean done;
|
||||
|
||||
public SingleJob(String name, Runnable runnable) {
|
||||
this.name = name;
|
||||
|
||||
Reference in New Issue
Block a user