Introduce a @Scheduler annotation

and make sure work is offloaded to an executor, so exceptions can be
caught.
This commit is contained in:
Torsten Grote
2016-11-18 10:48:20 -02:00
parent 37e61c97ea
commit 20708bc156
7 changed files with 57 additions and 20 deletions

View File

@@ -2,6 +2,7 @@ package org.briarproject.system;
import org.briarproject.api.lifecycle.LifecycleManager;
import org.briarproject.api.system.Clock;
import org.briarproject.api.system.Scheduler;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -17,6 +18,7 @@ public class SystemModule {
public static class EagerSingletons {
@Inject
@Scheduler
ScheduledExecutorService scheduledExecutorService;
}
@@ -33,6 +35,7 @@ public class SystemModule {
@Provides
@Singleton
@Scheduler
ScheduledExecutorService provideScheduledExecutorService(
LifecycleManager lifecycleManager) {
lifecycleManager.registerForShutdown(scheduler);