X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2Flru%2FLRUObject.java;h=5230723b70b5bd25fc6b5e3a6ac5412c071615a1;hb=HEAD;hp=3194d591e0b37e8712e8cabf3cc1afcb9549a754;hpb=c125a1755cc7c4a6241c3c5bf841c3db0ff2d658;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java index 3194d591e..5230723b7 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java @@ -5,18 +5,22 @@ import java.nio.file.Path; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; +import org.simantics.acorn.FileCache; import org.simantics.acorn.FileIO; import org.simantics.acorn.Persistable; import org.simantics.acorn.exception.AcornAccessVerificationException; import org.simantics.acorn.exception.IllegalAcornStateException; import org.simantics.utils.datastructures.Pair; +import org.slf4j.Logger; public abstract class LRUObject> implements Persistable { - + + public abstract Logger getLogger(); public static boolean VERIFY = true; // Final stuff final protected LRU LRU; + final protected FileCache fileCache; final private Semaphore mutex = new Semaphore(1); final private MapKey key; final private String fileName; @@ -37,8 +41,9 @@ public abstract class LRUObject LRU, MapKey key, Path readDirectory, String fileName, int offset, int length, boolean dirty, boolean resident) { + public LRUObject(LRU LRU, FileCache fileCache, MapKey key, Path readDirectory, String fileName, int offset, int length, boolean dirty, boolean resident) { this.LRU = LRU; + this.fileCache = fileCache; this.key = key; this.fileName = fileName; this.offset = offset; @@ -49,8 +54,8 @@ public abstract class LRUObject LRU, MapKey key, Path readDirectory, String fileName, boolean dirty, boolean resident) { - this(LRU, key, readDirectory, fileName, -1, -1, dirty, resident); + public LRUObject(LRU LRU, FileCache fileCache, MapKey key, Path readDirectory, String fileName, boolean dirty, boolean resident) { + this(LRU, fileCache, key, readDirectory, fileName, -1, -1, dirty, resident); } /* @@ -64,7 +69,7 @@ public abstract class LRUObject pair = toBytes(); byte[] data = pair.first; int length = pair.second; - FileIO fio = FileIO.get(bytes); + FileIO fio = fileCache.get(bytes); int offset = fio.saveBytes(data, length, overwrite()); setPosition(offset, length); } catch (AcornAccessVerificationException | IllegalAcornStateException e) { @@ -189,7 +194,7 @@ public abstract class LRUObject