Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@www.apache.org Received: (qmail 13871 invoked from network); 13 Oct 2003 14:29:50 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 13 Oct 2003 14:29:50 -0000 Received: (qmail 94944 invoked by uid 500); 13 Oct 2003 14:29:43 -0000 Delivered-To: apmail-jakarta-lucene-dev-archive@jakarta.apache.org Received: (qmail 94923 invoked by uid 500); 13 Oct 2003 14:29:43 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 94910 invoked by uid 500); 13 Oct 2003 14:29:42 -0000 Received: (qmail 94907 invoked from network); 13 Oct 2003 14:29:42 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 13 Oct 2003 14:29:42 -0000 Received: (qmail 13835 invoked by uid 1371); 13 Oct 2003 14:29:47 -0000 Date: 13 Oct 2003 14:29:47 -0000 Message-ID: <20031013142947.13834.qmail@minotaur.apache.org> From: otis@apache.org To: jakarta-lucene-cvs@apache.org Subject: cvs commit: jakarta-lucene/src/java/org/apache/lucene/store Lock.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N otis 2003/10/13 07:29:47 Modified: src/java/org/apache/lucene/store Lock.java Log: - Indentation cleanup. Revision Changes Path 1.5 +30 -29 jakarta-lucene/src/java/org/apache/lucene/store/Lock.java Index: Lock.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/Lock.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Lock.java 12 Aug 2003 15:05:03 -0000 1.4 +++ Lock.java 13 Oct 2003 14:29:47 -0000 1.5 @@ -68,19 +68,20 @@ * * * @author Doug Cutting + * @version $Id$ * @see Directory#makeLock(String) -*/ - + */ public abstract class Lock { - public static long LOCK_POLL_INTERVAL = 1000; + public static long LOCK_POLL_INTERVAL = 1000; + - /** Attempt to obtain exclusive access and immediately return + /** Attempts to obtain exclusive access and immediately return * upon success or failure. * @return true iff exclusive access is obtained */ public abstract boolean obtain() throws IOException; - /** Attempt to obtain an exclusive lock within amount + /** Attempts to obtain an exclusive lock within amount * of time given. Currently polls once per second until * lockWaitTimeout is passed. * @param lockWaitTimeout length of time to wait in ms @@ -88,24 +89,24 @@ * @throws IOException if lock wait times out or obtain() throws an IOException */ public boolean obtain(long lockWaitTimeout) throws IOException { - boolean locked = obtain(); - int maxSleepCount = (int)(lockWaitTimeout / LOCK_POLL_INTERVAL); - int sleepCount = 0; - while (!locked) { - if (++sleepCount == maxSleepCount) { - throw new IOException("Lock obtain timed out"); - } - try { - Thread.sleep(LOCK_POLL_INTERVAL); - } catch (InterruptedException e) { - throw new IOException(e.toString()); - } - locked = obtain(); - } - return locked; + boolean locked = obtain(); + int maxSleepCount = (int)(lockWaitTimeout / LOCK_POLL_INTERVAL); + int sleepCount = 0; + while (!locked) { + if (++sleepCount == maxSleepCount) { + throw new IOException("Lock obtain timed out"); + } + try { + Thread.sleep(LOCK_POLL_INTERVAL); + } catch (InterruptedException e) { + throw new IOException(e.toString()); + } + locked = obtain(); + } + return locked; } - /** Release exclusive access. */ + /** Releases exclusive access. */ public abstract void release(); /** Returns true if the resource is currently locked. Note that one must @@ -118,14 +119,14 @@ private Lock lock; private long lockWaitTimeout; - /** Constructs an executor that will grab the named lock. - * Defaults lockWaitTimeout to Lock.COMMIT_LOCK_TIMEOUT. - * @deprecated Kept only to avoid breaking existing code. - */ - public With(Lock lock) - { - this(lock, IndexWriter.COMMIT_LOCK_TIMEOUT); - } + /** Constructs an executor that will grab the named lock. + * Defaults lockWaitTimeout to Lock.COMMIT_LOCK_TIMEOUT. + * @deprecated Kept only to avoid breaking existing code. + */ + public With(Lock lock) + { + this(lock, IndexWriter.COMMIT_LOCK_TIMEOUT); + } /** Constructs an executor that will grab the named lock. */ public With(Lock lock, long lockWaitTimeout) { --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-dev-help@jakarta.apache.org