9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-30 04:29:05 +00:00

Fix locking

This commit is contained in:
Daniel Mills
2020-08-03 10:44:39 -04:00
parent 58a5aaed30
commit ef5115b76c
11 changed files with 93 additions and 58 deletions

View File

@@ -5,19 +5,20 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;
import java.util.concurrent.ForkJoinWorkerThread;
import java.util.concurrent.locks.ReentrantLock;
import com.volmit.iris.Iris;
public class GroupedExecutor
{
private int xc;
private ExecutorService service;
private ReentrantLock lock;
private IrisLock lock;
private KMap<String, Integer> mirror;
public GroupedExecutor(int threadLimit, int priority, String name)
{
xc = 1;
lock = new ReentrantLock();
lock = new IrisLock("GX");
mirror = new KMap<String, Integer>();
if(threadLimit == 1)
@@ -74,14 +75,23 @@ public class GroupedExecutor
return;
}
PrecisionStopwatch s = PrecisionStopwatch.start();
while(true)
{
J.sleep(1);
J.sleep(0);
if(mirror.get(g) == 0)
{
break;
}
if(s.getMilliseconds() > 30000)
{
Iris.warn("Couldn't unlock grouped task: " + g + "! Clearing Task Group Forcibly and timing out!");
mirror.remove(g);
break;
}
}
}

View File

@@ -31,7 +31,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
{
if(useFlip.flip())
{
unloadLast(60000);
unloadLast(60000 * 5);
}
}

View File

@@ -1,7 +1,6 @@
package com.volmit.iris.util;
import java.io.File;
import java.util.concurrent.locks.ReentrantLock;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
@@ -17,11 +16,11 @@ public class ResourceLoader<T extends IrisRegistrant>
protected KList<File> folderCache;
protected Class<? extends T> objectClass;
protected String cname;
protected ReentrantLock lock;
protected IrisLock lock;
public ResourceLoader(File root, String folderName, String resourceTypeName, Class<? extends T> objectClass)
{
lock = new ReentrantLock();
lock = new IrisLock("Res");
folderMapCache = new KMap<>();
this.objectClass = objectClass;
cname = objectClass.getCanonicalName();