You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/08/17 16:01:43 UTC

[10/11] jena git commit: Rename the writer lock. Tidy comments

Rename the writer lock. Tidy comments


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/711ab3e7
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/711ab3e7
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/711ab3e7

Branch: refs/heads/master
Commit: 711ab3e7affbfb35f0294ba993aaeb65c1248c7d
Parents: f972dde
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Aug 14 21:10:50 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Aug 14 21:10:50 2016 +0100

----------------------------------------------------------------------
 .../jena/tdb/transaction/TransactionManager.java    | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/711ab3e7/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
index da98a92..4753d78 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
@@ -119,8 +119,8 @@ public class TransactionManager
     // particular state creates the view datasetgraph and sets the  lastreader.
     private AtomicReference<DatasetGraphTDB> currentReaderView = new AtomicReference<>(null) ;
     
-    // Ensure single writer.
-    private Semaphore writersWaiting = new Semaphore(1, true) ;
+    // Ensure single writer. A writer calling begin(WRITE) blocks.  
+    private Semaphore writerPermits = new Semaphore(1, true) ;
     
     // All transactions need a "read" lock throughout their lifetime. 
     // Do not confuse with read/write transactions.  We need a 
@@ -485,23 +485,23 @@ public class TransactionManager
     }
     
     private void releaseWriterLock() {
-        int x = writersWaiting.availablePermits() ;
+        int x = writerPermits.availablePermits() ;
         if ( x != 0 )
-            throw new TDBTransactionException("TransactionCoordinator: Probably mismatch of enable/disableWriter calls") ;
-        writersWaiting.release() ;
+            throw new TDBTransactionException("TransactionCoordinator: Probably mismatch of enableWriters/blockWriters calls") ;
+        writerPermits.release() ;
     }
     
     private boolean acquireWriterLock(boolean canBlock) {
         if ( ! canBlock )
-            return writersWaiting.tryAcquire() ;
+            return writerPermits.tryAcquire() ;
         try { 
-            writersWaiting.acquire() ; 
+            writerPermits.acquire() ; 
             return true;
         } catch (InterruptedException e) { throw new TDBTransactionException(e) ; }
     }
     
     /** Block until no writers are active.
-     *  When this returns, yhis guarantees that the database is not changing
+     *  When this returns, it guarantees that the database is not changing
      *  and the jounral is flush to disk.
      * <p> 
      * The application must call {@link #enableWriters} later.