Search in sources :

Example 1 with Scheduler

use of com.github.robozonky.util.Scheduler in project robozonky by RoboZonky.

the class DaemonInvestmentMode method apply.

@Override
public ReturnCode apply(final Lifecycle lifecycle) {
    try (final Scheduler executor = Schedulers.INSTANCE.create(2, THREAD_FACTORY)) {
        // schedule the tasks
        executeDaemons(executor);
        // block until request to stop the app is received
        lifecycle.suspend();
        LOGGER.trace("Request to stop received.");
        // signal the end of standard operation
        return ReturnCode.OK;
    }
}
Also used : Scheduler(com.github.robozonky.util.Scheduler)

Example 2 with Scheduler

use of com.github.robozonky.util.Scheduler in project robozonky by RoboZonky.

the class SchedulerControlTest method check.

@Test
void check() {
    final ApiVersion v = new ApiVersion("master", UUID.randomUUID().toString(), UUID.randomUUID().toString(), OffsetDateTime.now(), "1.0.0");
    try (final Scheduler s = Schedulers.INSTANCE.create()) {
        final SchedulerControl rc = new SchedulerControl();
        rc.valueUnset(null);
        assertThat(s.isPaused()).isTrue();
        rc.valueSet(v);
        assertThat(s.isPaused()).isFalse();
    }
}
Also used : Scheduler(com.github.robozonky.util.Scheduler) Test(org.junit.jupiter.api.Test)

Aggregations

Scheduler (com.github.robozonky.util.Scheduler)2 Test (org.junit.jupiter.api.Test)1