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;
}
}
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();
}
}