Merge pull request #2610 from swazrgb/shutdown-executor
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.CreationException;
|
||||
import com.google.inject.Injector;
|
||||
@@ -685,8 +686,13 @@ public class ExternalPluginManager
|
||||
List<Plugin> scannedPlugins = new CopyOnWriteArrayList<>();
|
||||
|
||||
// some plugins get stuck on IO, so add some extra threads
|
||||
ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
|
||||
ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2,
|
||||
new ThreadFactoryBuilder()
|
||||
.setNameFormat("plugin-manager-%d")
|
||||
.build());
|
||||
|
||||
try
|
||||
{
|
||||
for (Plugin plugin : plugins)
|
||||
{
|
||||
Class<? extends Plugin> clazz = plugin.getClass();
|
||||
@@ -750,7 +756,16 @@ public class ExternalPluginManager
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
List<Runnable> unfinishedTasks = exec.shutdownNow();
|
||||
if (!unfinishedTasks.isEmpty())
|
||||
{
|
||||
// This shouldn't happen since we Future#get all tasks submitted to the executor
|
||||
log.warn("Did not complete all update tasks: {}", unfinishedTasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user