minor FullDataMetaFile write future fix

This commit is contained in:
James Seibel
2023-05-09 21:14:24 -05:00
parent ed6790458d
commit 62c78b133d
2 changed files with 11 additions and 9 deletions
@@ -31,7 +31,8 @@ public class FullDataFileHandler implements IFullDataSourceProvider
{
// Note: Single main thread only for now. May make it multi-thread later, depending on the usage.
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
final ExecutorService fileReaderThread = ThreadUtil.makeThreadPool(4, FullDataFileHandler.class.getSimpleName()+"Thread");
final ExecutorService fileReaderThread = ThreadUtil.makeThreadPool(4, FullDataFileHandler.class.getSimpleName()+"Thread");
final ConcurrentHashMap<DhSectionPos, FullDataMetaFile> files = new ConcurrentHashMap<>();
final IDhLevel level;
final File saveDir;
@@ -48,9 +49,9 @@ public class FullDataFileHandler implements IFullDataSourceProvider
/*
/**
* Caller must ensure that this method is called only once,
* and that this object is not used before this method is called.
* and that the {@link FullDataFileHandler} is not used before this method is called.
*/
@Override
public void addScannedFile(Collection<File> detectedFiles)
@@ -240,7 +241,6 @@ public class FullDataFileHandler implements IFullDataSourceProvider
/**
* Returns the {@link IFullDataSource} for the given section position. <Br>
* If the section hasn't been generated this will also send a generation call, which may take a while. <Br>
* The returned data source may be null. <Br> <Br>
*
* This call is concurrent. I.e. it supports being called by multiple threads at the same time.
@@ -402,9 +402,9 @@ public class FullDataFileHandler implements IFullDataSourceProvider
Consumer<IFullDataSource> onUpdated, Function<IFullDataSource, Boolean> updater)
{
boolean changed = updater.apply(source);
// if (changed)
// if (changed)
// {
// metaData.dataVersion.incrementAndGet();
// metaData.dataVersion.incrementAndGet();
// }
if (source instanceof IIncompleteFullDataSource)
@@ -143,10 +143,10 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
{
debugPhantomLifeCycleCheck();
CompletableFuture<IFullDataSource> cached = this.getCachedDataSourceAsync();
if (cached != null)
CompletableFuture<IFullDataSource> getCachedFuture = this.getCachedDataSourceAsync();
if (getCachedFuture != null)
{
return cached;
return getCachedFuture;
}
@@ -346,6 +346,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
new DataObjTracker(fullDataSource);
this.cachedFullDataSource = new SoftReference<>(fullDataSource);
}
this.dataSourceWriteQueueFuture = null;
this.inCacheWriteAccessFuture.set(null);
return fullDataSource;
@@ -356,6 +357,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
}
// the data source hasn't been loaded
// and isn't in the process of being loaded
return null;