ozeigermann 2005/01/09 11:10:11 Modified: transaction/src/java/org/apache/commons/transaction/locking GenericLockManager.java Log: Reducing the number of unnecassary deadlock checks by moving the check out of the wait loop Revision Changes Path 1.18 +15 -12 jakarta-commons/transaction/src/java/org/apache/commons/transaction/locking/GenericLockManager.java Index: GenericLockManager.java =================================================================== RCS file: /home/cvs/jakarta-commons/transaction/src/java/org/apache/commons/transaction/locking/GenericLockManager.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- GenericLockManager.java 9 Jan 2005 15:12:11 -0000 1.17 +++ GenericLockManager.java 9 Jan 2005 19:10:10 -0000 1.18 @@ -168,8 +168,8 @@ GenericLock.LockOwner lockWaiter = new GenericLock.LockOwner(ownerId, targetLockLevel, compatibility, preferred); + boolean acquired = false; try { - boolean acquired = false; // detection for deadlocks and time outs is rather expensive, // so we wait for the lock for a @@ -190,19 +190,22 @@ addOwner(ownerId, lock); return; } - + } catch (InterruptedException e) { + throw new LockException("Interrupted", LockException.CODE_INTERRUPTED, resourceId); + } + try { lock.registerWaiter(lockWaiter); + boolean deadlock = wouldDeadlock(ownerId, new HashSet()); + if (deadlock) { + throw new LockException("Lock would cause deadlock", + LockException.CODE_DEADLOCK_VICTIM, resourceId); + } + while (!acquired && waitEnd > now) { // first be sure all locks are stolen from owners that have already timed out releaseTimedOutOwners(); - - boolean deadlock = wouldDeadlock(ownerId, new HashSet()); - if (deadlock) { - throw new LockException("Lock would cause deadlock", - LockException.CODE_DEADLOCK_VICTIM, resourceId); - } // if there are owners we conflict with lets see if one of them globally times // out earlier than this lock, if so we will wake up then to check again
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]