Use a single thread for DB access from the UI.

The UI may access the DB in response to UI or DB events; to maintain a
consistent view of the DB's contents, the tasks performing these
accesses must be prevented from overlapping, and must produce consistent
results if reordered. A single-threaded executor and latches are used to
prevent tasks from overlapping, without blocking non-UI access to the
DB.
This commit is contained in:
akwizgran
2013-03-18 22:13:21 +00:00
parent b280e4cbcd
commit e32698db6b
6 changed files with 159 additions and 91 deletions

View File

@@ -0,0 +1,18 @@
package net.sf.briar.api.android;
import static java.lang.annotation.ElementType.FIELD;
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 accessing the database from the UI.
*/
@BindingAnnotation
@Target({ FIELD, PARAMETER })
@Retention(RUNTIME)
public @interface DatabaseUiExecutor {}