Compiling

This commit is contained in:
cyberpwn
2021-08-22 03:04:30 -04:00
parent beb80f0422
commit 5bf6687f1f
25 changed files with 434 additions and 16 deletions

View File

@@ -0,0 +1,42 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.scheduling.jobs;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
public abstract class ParallelQueueJob<T> extends QueueJob<T> {
@Override
public void execute() {
while (queue.isNotEmpty()) {
BurstExecutor b = MultiBurst.burst.burst(queue.size());
KList<T> q = queue.copy();
queue.clear();
for(T i : q)
{
b.queue(() -> {
execute(i);
completeWork();
});
}
b.complete();
}
}
}

View File

@@ -18,27 +18,32 @@
package com.volmit.iris.util.scheduling.jobs;
import com.sun.jna.platform.unix.X11;
import com.volmit.iris.util.collection.KList;
import java.util.concurrent.atomic.AtomicInteger;
public abstract class QueueJob<T> implements Job {
private final KList<T> queue;
private int totalWork;
private int completed;
final KList<T> queue;
protected int totalWork;
private AtomicInteger completed;
public QueueJob() {
totalWork = 0;
completed = 0;
completed = new AtomicInteger(0);
queue = new KList<>();
}
public void queue(T t) {
public QueueJob queue(T t) {
queue.add(t);
totalWork++;
return this;
}
public void queue(KList<T> f) {
public QueueJob queue(KList<T> f) {
queue.addAll(f);
totalWork += f.size();
return this;
}
public abstract void execute(T t);
@@ -54,7 +59,7 @@ public abstract class QueueJob<T> implements Job {
@Override
public void completeWork() {
completed++;
completed.incrementAndGet();
}
@Override
@@ -64,6 +69,6 @@ public abstract class QueueJob<T> implements Job {
@Override
public int getWorkCompleted() {
return completed;
return completed.get();
}
}