Skip to content

Commit ba7fe17

Browse files
committed
Remove asset loader thread pool
It was only used in getAssetAsynchronously which spawned a task that either returns after finding the asset in the cache or added a task to another thread pool. Determining if a file exists is potentially slow on Windows and this thread pool potentially allowed the caller to be reponsive but it's also a source of potential deadlocks if the listener callback indirectly requests an asset load such as an addon's onInit script loading the JavaScript asset. The git logs don't go far enough back to determine whether the thread pool is intentional or vestigial.
1 parent b02a6a5 commit ba7fe17

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

src/main/java/net/rptools/maptool/model/AssetManager.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ public class AssetManager {
9090
/** Used to load assets from storage */
9191
private static AssetLoader assetLoader = new AssetLoader();
9292

93-
private static ExecutorService assetLoaderThreadPool = Executors.newFixedThreadPool(1);
9493
private static ExecutorService assetWriterThreadPool = Executors.newFixedThreadPool(1);
9594

9695
static {
@@ -286,25 +285,22 @@ public static void putAsset(Asset asset) {
286285
public static void getAssetAsynchronously(
287286
final MD5Key id, final AssetAvailableListener... listeners) {
288287

289-
assetLoaderThreadPool.submit(
290-
() -> {
291-
Asset asset = getAsset(id);
288+
Asset asset = getAsset(id);
292289

293-
// Simplest case, we already have it
294-
if (asset != null && asset.getData() != null && asset.getData().length > 0) {
295-
for (AssetAvailableListener listener : listeners) {
296-
listener.assetAvailable(id);
297-
}
290+
// Simplest case, we already have it
291+
if (asset != null && asset.getData() != null && asset.getData().length > 0) {
292+
for (AssetAvailableListener listener : listeners) {
293+
listener.assetAvailable(id);
294+
}
298295

299-
return;
300-
}
296+
return;
297+
}
301298

302-
// Let's get it from the server
303-
// As a last resort we request the asset from the server
304-
if (!isAssetRequested(id)) {
305-
requestAssetFromServer(id, listeners);
306-
}
307-
});
299+
// Let's get it from the server
300+
// As a last resort we request the asset from the server
301+
if (!isAssetRequested(id)) {
302+
requestAssetFromServer(id, listeners);
303+
}
308304
}
309305

310306
/**

0 commit comments

Comments
 (0)