runelite-client: add synchronous job scheduler
Convert existing plugins to use it, so that the code all runs on the same main game thread. Fixes various thread related issues caused from accessing game state from executor threads.
This commit is contained in:
@@ -49,6 +49,7 @@ import net.runelite.client.events.SessionClose;
|
||||
import net.runelite.client.events.SessionOpen;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.task.Scheduler;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||
import net.runelite.http.api.account.AccountClient;
|
||||
@@ -75,7 +76,8 @@ public class RuneLite
|
||||
private final MenuManager menuManager = new MenuManager(this);
|
||||
private OverlayRenderer renderer;
|
||||
private final EventBus eventBus = new EventBus(this::eventExceptionHandler);
|
||||
private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(4);
|
||||
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
private final Scheduler scheduler = new Scheduler(this);
|
||||
private WSClient wsclient;
|
||||
|
||||
private AccountSession accountSession;
|
||||
@@ -327,6 +329,11 @@ public class RuneLite
|
||||
return executor;
|
||||
}
|
||||
|
||||
public Scheduler getScheduler()
|
||||
{
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
public static TrayIcon getTrayIcon()
|
||||
{
|
||||
return trayIcon;
|
||||
|
||||
Reference in New Issue
Block a user