mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Use a lock to ensure transaction isolation. #272
This commit is contained in:
@@ -45,8 +45,9 @@ public interface DatabaseComponent {
|
||||
|
||||
/**
|
||||
* Starts a new transaction and returns an object representing it.
|
||||
* @param readOnly true if the transaction will only be used for reading.
|
||||
*/
|
||||
Transaction startTransaction() throws DbException;
|
||||
Transaction startTransaction(boolean readOnly) throws DbException;
|
||||
|
||||
/**
|
||||
* Ends a transaction. If the transaction is marked as complete, the
|
||||
|
||||
@@ -12,12 +12,14 @@ import java.util.List;
|
||||
public class Transaction {
|
||||
|
||||
private final Object txn;
|
||||
private final boolean readOnly;
|
||||
|
||||
private List<Event> events = null;
|
||||
private boolean complete = false;
|
||||
|
||||
public Transaction(Object txn) {
|
||||
public Transaction(Object txn, boolean readOnly) {
|
||||
this.txn = txn;
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,6 +30,13 @@ public class Transaction {
|
||||
return txn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the transaction can only be used for reading.
|
||||
*/
|
||||
public boolean isReadOnly() {
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches an event to be broadcast when the transaction has been
|
||||
* committed.
|
||||
|
||||
Reference in New Issue
Block a user