diff options
author | eea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-09 18:46:56 +0000 |
---|---|---|
committer | eea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-09 18:46:56 +0000 |
commit | bb32ac6034b00ed18e8f94a3283cff53357ce9aa (patch) | |
tree | f265ef1882d0a1e600347909c593efbadda3ff43 /java | |
parent | 90c6c666f5408ace31c298d825eb857f8a959a18 (diff) | |
download | ATCD-bb32ac6034b00ed18e8f94a3283cff53357ce9aa.tar.gz |
Minor correction (checked in old version last time). Removes
InterruptedExceptions.
Diffstat (limited to 'java')
-rw-r--r-- | java/src/Token.java | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/java/src/Token.java b/java/src/Token.java index f8c001573e0..c112acdb653 100644 --- a/java/src/Token.java +++ b/java/src/Token.java @@ -65,11 +65,7 @@ public class Token { try { - while (true) { - try { - return this.acquire (null); - } catch (InterruptedException e) { } - } + return this.acquire (null); } catch (TimeoutException e) { @@ -90,7 +86,7 @@ public class Token * 1 if <sleepHook> is called. * -1 if failure occurs (timeout) */ - public int acquire (TimeValue timeout) + public int acquire (TimeValue timeout) throws TimeoutException { int result = 0; WaitObject snl = new WaitObject (); @@ -115,7 +111,15 @@ public class Token { result = 1; sleepHook(); - snl.timedWait(timeout); + + while (mustWait) { + try { + snl.timedWait(timeout); + mustWait = false; + } catch (InterruptedException e) { + // must keep waiting + } + } } // Set the owner of the token @@ -177,9 +181,8 @@ public class Token * entries to skip over before inserting our thread into the list of * waiters (e.g.,requeuePosition == 0 means "insert at front of the * queue"). - *@exception InterruptedException exception during wait */ - public void renew (int requeuePosition) throws InterruptedException + public void renew (int requeuePosition) { try { @@ -208,10 +211,9 @@ public class Token *@param timeout Throw a TimeoutException if the token isn't renewed * before this absolute time timeout. *@exception TimeoutException exception if timeout occurs - *@exception InterruptedException exception during wait */ public void renew (int requeuePosition, TimeValue timeout) - throws InterruptedException, TimeoutException + throws TimeoutException { WaitObject snl = null; int saveNestingLevel = 0; @@ -261,8 +263,15 @@ public class Token snl.condition (false); // Wait until the given absolute time (or until notified // if the timeout is null) - try { - snl.timedWait (timeout); + boolean mustWait = true; + while (mustWait) { + try { + snl.timedWait (timeout); + mustWait = false; + } catch (InterruptedException e) { + // must keep waiting + } + } } // Restore the nesting level and current owner of the lock this.nestingLevel_ = saveNestingLevel; |