mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Moved lifecycle management into briar-core and reconfigured executors.
CryptoExecutor and DatabaseExecutor now use bounded thread pools with unbounded queues, since running too many tasks in parallel is likely to harm performance; IncomingConnectionExecutor, PluginExecutor and ReliabilityExecutor use unbounded thread pools with direct handoff, since their tasks may run indefinitely. There are no longer any bounded executors, and all executors discard tasks when shutting down, which fixes issue #3612189. Responsibility for starting and stopping services has been moved from BriarService in briar-android to LifecycleManagerImpl in briar-core. However, BriarService is still responsible for stopping the Android-specific executors, which is ugly. It would be better if executors registered themselves with LifecycleManager.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package net.sf.briar.api.lifecycle;
|
||||
|
||||
public interface LifecycleManager {
|
||||
|
||||
/** Starts any services that need to be started at startup. */
|
||||
public void startServices();
|
||||
|
||||
/** Stops any services that need to be stopped at shutdown. */
|
||||
public void stopServices();
|
||||
|
||||
/** Waits for the database to be opened before returning. */
|
||||
public void waitForDatabase() throws InterruptedException;
|
||||
|
||||
/** Waits for all services to start before returning. */
|
||||
public void waitForStartup() throws InterruptedException;
|
||||
|
||||
/** Waits for all services to stop before returning. */
|
||||
public void waitForShutdown() throws InterruptedException;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.sf.briar.api.reliability;
|
||||
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.google.inject.BindingAnnotation;
|
||||
|
||||
/** Annotation for injecting the executor used by reliability layers. */
|
||||
@BindingAnnotation
|
||||
@Target({ PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface ReliabilityExecutor {}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.sf.briar.api.transport;
|
||||
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.google.inject.BindingAnnotation;
|
||||
|
||||
/**
|
||||
* Annotation for injecting the executor for recognising incoming connections.
|
||||
*/
|
||||
@BindingAnnotation
|
||||
@Target({ PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface IncomingConnectionExecutor {}
|
||||
Reference in New Issue
Block a user