summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/txn
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2009-12-22 01:15:07 +0000
committerBrian S. O'Neill <bronee@gmail.com>2009-12-22 01:15:07 +0000
commit4684549782accd0ffba1aefd15d42918effeddfd (patch)
treee4b44a9c85b8f4a2be60f94268c7f92d55cdf337 /src/main/java/com/amazon/carbonado/txn
parentca6d4484142d8144f7567a37ed448babe294fda8 (diff)
Added isClosed method to Repository.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/txn')
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionManager.java4
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionScope.java8
2 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
index 36d2e22..0f203aa 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
@@ -134,6 +134,10 @@ public abstract class TransactionManager<Txn> {
}
}
+ public synchronized boolean isClosed() {
+ return mState != OPEN;
+ }
+
/**
* Returns supported isolation level, which may be higher. If isolation
* level cannot go higher (or lower than parent) then return null.
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
index bce8ca6..4def72d 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
@@ -57,6 +57,14 @@ public class TransactionScope<Txn> {
TransactionScope(TransactionManager<Txn> txnMgr, boolean closed) {
mTxnMgr = txnMgr;
mLock = new ReentrantLock(true);
+ if (closed) {
+ mLock.lock();
+ try {
+ mClosed = true;
+ } finally {
+ mLock.unlock();
+ }
+ }
}
/**