minor refactoring
This commit is contained in:
@@ -42,7 +42,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
|
||||
// SoftReference<LodDataSource>, or - Non-dirty file that can be GCed
|
||||
// CompletableFuture<LodDataSource>, or - File that is being loaded. No guarantee that the type is promotable or not
|
||||
// null - Nothing is loaded or being loaded
|
||||
AtomicReference<Object> data = new AtomicReference<Object>(null);
|
||||
AtomicReference<Object> data = new AtomicReference<>(null);
|
||||
|
||||
//TODO: use ConcurrentAppendSingleSwapContainer<LodDataSource> instead of below:
|
||||
private static class GuardedMultiAppendQueue {
|
||||
|
||||
@@ -134,28 +134,28 @@ public class RenderMetaDataFile extends AbstractMetaDataContainerFile
|
||||
public CompletableFuture<ColumnRenderSource> loadOrGetCached(Executor fileReaderThreads, IDhLevel level)
|
||||
{
|
||||
Object obj = this.data.get();
|
||||
|
||||
|
||||
CompletableFuture<ColumnRenderSource> cached = this._readCached(obj);
|
||||
if (cached != null)
|
||||
{
|
||||
return cached;
|
||||
}
|
||||
|
||||
|
||||
// Create an empty and non-completed future.
|
||||
// Note: I do this before actually filling in the future so that I can ensure only
|
||||
// one task is submitted to the thread pool.
|
||||
CompletableFuture<ColumnRenderSource> loadRenderSourceFuture = new CompletableFuture<>();
|
||||
|
||||
|
||||
// Would use faster and non-nesting Compare and exchange. But java 8 doesn't have it! :(
|
||||
boolean worked = this.data.compareAndSet(obj, loadRenderSourceFuture);
|
||||
if (!worked)
|
||||
{
|
||||
return this.loadOrGetCached(fileReaderThreads, level);
|
||||
}
|
||||
|
||||
|
||||
// Now, there should only ever be one thread at a time here due to the CAS operation above.
|
||||
|
||||
|
||||
|
||||
|
||||
// After cas. We are in exclusive control.
|
||||
if (!this.doesFileExist)
|
||||
{
|
||||
|
||||
@@ -324,6 +324,14 @@ public class RenderSourceFileHandler implements ILodRenderSourceProvider
|
||||
return renderSource;
|
||||
}
|
||||
|
||||
public void onReadRenderSourceFromCache(RenderMetaDataFile file, ColumnRenderSource data)
|
||||
{
|
||||
// if (!this.fullDataSourceProvider.isCacheVersionValid(file.pos, file.metaData.dataVersion.get()))
|
||||
// {
|
||||
this.updateCache(data, file);
|
||||
// }
|
||||
}
|
||||
|
||||
private void write(ColumnRenderSource currentRenderSource, RenderMetaDataFile file,
|
||||
ColumnRenderSource newRenderSource)
|
||||
{
|
||||
@@ -341,14 +349,6 @@ public class RenderSourceFileHandler implements ILodRenderSourceProvider
|
||||
file.save(currentRenderSource);
|
||||
}
|
||||
|
||||
public void onReadRenderSourceFromCache(RenderMetaDataFile file, ColumnRenderSource data)
|
||||
{
|
||||
// if (!this.fullDataSourceProvider.isCacheVersionValid(file.pos, file.metaData.dataVersion.get()))
|
||||
// {
|
||||
this.updateCache(data, file);
|
||||
// }
|
||||
}
|
||||
|
||||
public boolean refreshRenderSource(ColumnRenderSource renderSource)
|
||||
{
|
||||
RenderMetaDataFile file = this.filesBySectionPos.get(renderSource.getSectionPos());
|
||||
|
||||
Reference in New Issue
Block a user