diff options
author | Adam Vandenberg <flangy@gmail.com> | 2014-03-05 15:55:08 -0800 |
---|---|---|
committer | broneill <bronee@gmail.com> | 2014-03-06 07:17:24 -0800 |
commit | 96d2600cff43f72700c00473bb813ee5c01c30ca (patch) | |
tree | 8a591a78d82b8739dd56e6aa975d53fbf3ee824c /src/main/java/com/amazon/carbonado/txn | |
parent | 72df69d2aa512e5a6168df119aecdafd07a251c7 (diff) |
Implement AutoCloseable
Diffstat (limited to 'src/main/java/com/amazon/carbonado/txn')
-rw-r--r-- | src/main/java/com/amazon/carbonado/txn/TransactionPair.java | 5 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/txn/TransactionScope.java | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionPair.java b/src/main/java/com/amazon/carbonado/txn/TransactionPair.java index f719a79..e247661 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionPair.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionPair.java @@ -110,4 +110,9 @@ public class TransactionPair implements Transaction { public boolean preCommit() throws PersistException {
return mPrimaryTransaction.preCommit() ? mSecondaryTransaction.preCommit() : false;
}
+
+ @Override
+ public void close() throws PersistException {
+ exit();
+ }
}
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java index 6e94b91..6061c62 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java @@ -216,7 +216,7 @@ public class TransactionScope<Txn> { mLock.unlock();
}
}
-
+
/**
* Returns the implementation for the active transaction, only if it exists.
* (does not create a transaction like getTxn()
@@ -323,10 +323,10 @@ public class TransactionScope<Txn> { mLock.unlock();
return;
}
-
+
Map<Class<?>, CursorList<TransactionImpl<Txn>>> cursors;
try {
- cursors = mCursors;
+ cursors = mCursors;
// Ensure that map is freed promptly. Thread-local reference to
// this scope otherwise keeps map and its contents lingering around
@@ -427,6 +427,11 @@ public class TransactionScope<Txn> { }
}
+ @Override
+ public void close() throws PersistException {
+ exit();
+ }
+
public void commit() throws PersistException {
TransactionScope<Txn> scope = mScope;
scope.mLock.lock();
|