[ https://issues.apache.org/jira/browse/JENA-1209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15375340#comment-15375340 ]
ASF GitHub Bot commented on JENA-1209: -------------------------------------- Github user ajs6f commented on a diff in the pull request: https://github.com/apache/jena/pull/154#discussion_r70663415 --- Diff: jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java --- @@ -436,8 +469,96 @@ public void notifyAbort(Transaction transaction) switch ( transaction.getMode() ) { case READ: break ; - case WRITE: writersWaiting.release() ; + case WRITE: releaseWriterLock(); + } + } + + private void releaseWriterLock() { + int x = writersWaiting.availablePermits() ; + if ( x != 0 ) + throw new TDBTransactionException("TransactionCoordinator: Probably mismatch of enable/disableWriter calls") ; + writersWaiting.release() ; + } + + private boolean acquireWriterLock(boolean canBlock) { + if ( ! canBlock ) + return writersWaiting.tryAcquire() ; + try { + writersWaiting.acquire() ; + return true; + } catch (InterruptedException e) { throw new TDBTransactionException(e) ; } + } + + /** Block until no writers are active. --- End diff -- Just a "wordsmithing" suggestion: this might be better as `waitForWriters` or the like. `disableWriters` sounds a bit like the caller is going to have some kind of actual impact on the outstanding writers, but in truth the caller is just waiting for them to finish on their own, right? Same for the next method. > Add "exclusive mode" for TDB > ---------------------------- > > Key: JENA-1209 > URL: https://issues.apache.org/jira/browse/JENA-1209 > Project: Apache Jena > Issue Type: Bug > Reporter: Andy Seaborne > Assignee: Andy Seaborne > > In exclusive mode, the current thread is guaranteed there are no other read > or write transactions active. > This allows specialized code to _*very*_ carefully manipulate the internals > of the database. -- This message was sent by Atlassian JIRA (v6.3.4#6332)