clientthread: implement executor and make Schedulers.single() use it
This commit is contained in:
@@ -25,21 +25,38 @@
|
|||||||
package net.runelite.client.callback;
|
package net.runelite.client.callback;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ClientThread
|
public class ClientThread implements Executor
|
||||||
{
|
{
|
||||||
private final ConcurrentLinkedQueue<BooleanSupplier> invokes = new ConcurrentLinkedQueue<>();
|
private final ConcurrentLinkedQueue<BooleanSupplier> invokes = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
|
private final Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private ClientThread(Client client)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
|
||||||
|
RxJavaPlugins.setSingleSchedulerHandler(old -> Schedulers.from(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(@NotNull Runnable r)
|
||||||
|
{
|
||||||
|
invoke(r);
|
||||||
|
}
|
||||||
|
|
||||||
public void invoke(Runnable r)
|
public void invoke(Runnable r)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user