Use wakeful IO executor for polling, reconnection tasks.

This commit is contained in:
akwizgran
2020-08-10 16:49:46 +01:00
parent 086c10abc0
commit 434b8a37f3
2 changed files with 20 additions and 20 deletions

View File

@@ -58,7 +58,7 @@ public class PollerImplTest extends BrambleMockTestCase {
private final Future<?> future = context.mock(Future.class);
private final SecureRandom random;
private final Executor ioExecutor = new ImmediateExecutor();
private final Executor wakefulIoExecutor = new ImmediateExecutor();
private final TransportId transportId = getTransportId();
private final ContactId contactId = getContactId();
private final TransportProperties properties = new TransportProperties();
@@ -74,7 +74,7 @@ public class PollerImplTest extends BrambleMockTestCase {
@Before
public void setUp() {
poller = new PollerImpl(ioExecutor, scheduler, connectionManager,
poller = new PollerImpl(wakefulIoExecutor, scheduler, connectionManager,
connectionRegistry, pluginManager, transportPropertyManager,
random, clock);
}
@@ -234,7 +234,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with((long) pollingInterval),
with(wakefulIoExecutor), with((long) pollingInterval),
with(MILLISECONDS));
will(returnValue(future));
}});
@@ -263,7 +263,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with((long) pollingInterval),
with(wakefulIoExecutor), with((long) pollingInterval),
with(MILLISECONDS));
will(returnValue(future));
// Second event
@@ -306,7 +306,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with((long) pollingInterval),
with(wakefulIoExecutor), with((long) pollingInterval),
with(MILLISECONDS));
will(returnValue(future));
// Second event
@@ -323,7 +323,7 @@ public class PollerImplTest extends BrambleMockTestCase {
will(returnValue(now + 1));
oneOf(future).cancel(false);
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with((long) pollingInterval - 2),
with(wakefulIoExecutor), with((long) pollingInterval - 2),
with(MILLISECONDS));
}});
@@ -350,7 +350,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with(0L), with(MILLISECONDS));
with(wakefulIoExecutor), with(0L), with(MILLISECONDS));
will(returnValue(future));
will(new RunAction());
// Running the polling task schedules the next polling task
@@ -361,7 +361,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with((long) (pollingInterval * 0.5)),
with(wakefulIoExecutor), with((long) (pollingInterval * 0.5)),
with(MILLISECONDS));
will(returnValue(future));
// Get the transport properties and connected contacts
@@ -394,7 +394,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with(0L), with(MILLISECONDS));
with(wakefulIoExecutor), with(0L), with(MILLISECONDS));
will(returnValue(future));
will(new RunAction());
// Running the polling task schedules the next polling task
@@ -405,7 +405,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with((long) (pollingInterval * 0.5)),
with(wakefulIoExecutor), with((long) (pollingInterval * 0.5)),
with(MILLISECONDS));
will(returnValue(future));
// Get the transport properties and connected contacts
@@ -436,7 +436,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with(0L), with(MILLISECONDS));
with(wakefulIoExecutor), with(0L), with(MILLISECONDS));
will(returnValue(future));
// The plugin is deactivated before the task runs - cancel the task
oneOf(future).cancel(false);
@@ -460,7 +460,7 @@ public class PollerImplTest extends BrambleMockTestCase {
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(scheduler).schedule(with(any(Runnable.class)),
with(ioExecutor), with((long) pollingInterval),
with(wakefulIoExecutor), with((long) pollingInterval),
with(MILLISECONDS));
will(returnValue(future));
}});