Don't redundantly use wakeful IO executor.

This commit is contained in:
akwizgran
2020-08-12 14:45:39 +01:00
parent 79f3a77e1a
commit cc67237893
2 changed files with 21 additions and 17 deletions

View File

@@ -27,6 +27,7 @@ import org.briarproject.bramble.api.properties.TransportProperties;
import org.briarproject.bramble.api.properties.TransportPropertyManager;
import org.briarproject.bramble.api.system.Clock;
import org.briarproject.bramble.api.system.TaskScheduler;
import org.briarproject.bramble.api.system.Wakeful;
import org.briarproject.bramble.api.system.WakefulIoExecutor;
import java.security.SecureRandom;
@@ -57,7 +58,7 @@ class PollerImpl implements Poller, EventListener {
private static final Logger LOG = getLogger(PollerImpl.class.getName());
private final Executor wakefulIoExecutor;
private final Executor ioExecutor, wakefulIoExecutor;
private final TaskScheduler scheduler;
private final ConnectionManager connectionManager;
private final ConnectionRegistry connectionRegistry;
@@ -70,7 +71,8 @@ class PollerImpl implements Poller, EventListener {
private final Map<TransportId, ScheduledPollTask> tasks;
@Inject
PollerImpl(@WakefulIoExecutor Executor wakefulIoExecutor,
PollerImpl(@IoExecutor Executor ioExecutor,
@WakefulIoExecutor Executor wakefulIoExecutor,
TaskScheduler scheduler,
ConnectionManager connectionManager,
ConnectionRegistry connectionRegistry,
@@ -78,6 +80,7 @@ class PollerImpl implements Poller, EventListener {
TransportPropertyManager transportPropertyManager,
SecureRandom random,
Clock clock) {
this.ioExecutor = ioExecutor;
this.wakefulIoExecutor = wakefulIoExecutor;
this.scheduler = scheduler;
this.connectionManager = connectionManager;
@@ -190,8 +193,8 @@ class PollerImpl implements Poller, EventListener {
// it will abort safely when it finds it's been replaced
if (scheduled != null) scheduled.future.cancel(false);
PollTask task = new PollTask(p, due, randomiseNext);
Future<?> future = scheduler.schedule(task, wakefulIoExecutor,
delay, MILLISECONDS);
Future<?> future = scheduler.schedule(task, ioExecutor, delay,
MILLISECONDS);
tasks.put(t, new ScheduledPollTask(task, future));
}
} finally {