Javadocs and unit tests.

This commit is contained in:
akwizgran
2011-07-01 12:07:00 +01:00
parent b29a024c2a
commit 0ed2a7c9e7
23 changed files with 235 additions and 59 deletions

View File

@@ -21,6 +21,10 @@ import net.sf.briar.api.protocol.MessageId;
import com.google.inject.Inject;
import com.google.inject.Provider;
/**
* An implementation of DatabaseComponent using reentrant read-write locks.
* This implementation can allow writers to starve.
*/
class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
private static final Logger LOG =
@@ -28,8 +32,7 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
/*
* Locks must always be acquired in alphabetical order. See the Database
* interface to find out which calls require which locks. Note: this
* implementation can allow writers to starve.
* interface to find out which calls require which locks.
*/
private final ReentrantReadWriteLock contactLock =
@@ -112,6 +115,8 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
try {
Txn txn = db.startTransaction();
try {
// Don't store the message if the user has
// unsubscribed from the group
if(db.containsSubscription(txn, m.getGroup())) {
boolean added = storeMessage(txn, m, null);
assert added;