mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Document the contract of DatabaseExecutor.
This commit is contained in:
@@ -10,7 +10,13 @@ import java.lang.annotation.Target;
|
|||||||
|
|
||||||
import com.google.inject.BindingAnnotation;
|
import com.google.inject.BindingAnnotation;
|
||||||
|
|
||||||
/** Annotation for injecting the executor for database tasks. */
|
/**
|
||||||
|
* Annotation for injecting the executor for database tasks.
|
||||||
|
* <p>
|
||||||
|
* The contract of this executor is that tasks are executed in the order
|
||||||
|
* they're submitted, tasks are not executed concurrently, and submitting a
|
||||||
|
* task will never block.
|
||||||
|
*/
|
||||||
@BindingAnnotation
|
@BindingAnnotation
|
||||||
@Target({ FIELD, METHOD, PARAMETER })
|
@Target({ FIELD, METHOD, PARAMETER })
|
||||||
@Retention(RUNTIME)
|
@Retention(RUNTIME)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class CryptoModule extends AbstractModule {
|
|||||||
private final ExecutorService cryptoExecutor;
|
private final ExecutorService cryptoExecutor;
|
||||||
|
|
||||||
public CryptoModule() {
|
public CryptoModule() {
|
||||||
// The queue is unbounded, so tasks can be dependent
|
// Use an unbounded queue
|
||||||
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
|
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
|
||||||
// Discard tasks that are submitted during shutdown
|
// Discard tasks that are submitted during shutdown
|
||||||
RejectedExecutionHandler policy =
|
RejectedExecutionHandler policy =
|
||||||
@@ -38,6 +38,7 @@ public class CryptoModule extends AbstractModule {
|
|||||||
60, SECONDS, queue, policy);
|
60, SECONDS, queue, policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(CryptoComponent.class).to(
|
bind(CryptoComponent.class).to(
|
||||||
CryptoComponentImpl.class).in(Singleton.class);
|
CryptoComponentImpl.class).in(Singleton.class);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class DatabaseModule extends AbstractModule {
|
|||||||
private final ExecutorService databaseExecutor;
|
private final ExecutorService databaseExecutor;
|
||||||
|
|
||||||
public DatabaseModule() {
|
public DatabaseModule() {
|
||||||
// The queue is unbounded, so tasks can be dependent
|
// Use an unbounded queue
|
||||||
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
|
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
|
||||||
// Discard tasks that are submitted during shutdown
|
// Discard tasks that are submitted during shutdown
|
||||||
RejectedExecutionHandler policy =
|
RejectedExecutionHandler policy =
|
||||||
|
|||||||
Reference in New Issue
Block a user