diff options
| author | Starla Insigna <hatkirby@fourisland.com> | 2009-02-03 18:00:24 -0500 |
|---|---|---|
| committer | Starla Insigna <hatkirby@fourisland.com> | 2009-02-03 18:00:24 -0500 |
| commit | ce6ae1b56e4f6548dc19974474c8ee2d8cece13a (patch) | |
| tree | 841a308e44cd0441ec86c07189d3a451b286962a | |
| parent | c791c138d4d73b495c8a355ae01bca754e1ce66b (diff) | |
| download | fourpuzzle-ce6ae1b56e4f6548dc19974474c8ee2d8cece13a.tar.gz fourpuzzle-ce6ae1b56e4f6548dc19974474c8ee2d8cece13a.tar.bz2 fourpuzzle-ce6ae1b56e4f6548dc19974474c8ee2d8cece13a.zip | |
Fixed [Gotez06] InterruptedException violation
6 files changed, 18 insertions, 38 deletions
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java index c0c2c3b..f577cc2 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | 5 | ||
| 6 | package com.fourisland.fourpuzzle.gamestate.mapview.event; | 6 | package com.fourisland.fourpuzzle.gamestate.mapview.event; |
| 7 | 7 | ||
| 8 | import com.fourisland.fourpuzzle.gamestate.mapview.Map; | ||
| 9 | import java.util.concurrent.Future; | 8 | import java.util.concurrent.Future; |
| 10 | 9 | ||
| 11 | /** | 10 | /** |
| @@ -22,9 +21,9 @@ public abstract class EventCall extends SpecialEvent implements Runnable { | |||
| 22 | } | 21 | } |
| 23 | }; | 22 | }; |
| 24 | } | 23 | } |
| 25 | |||
| 26 | public abstract void run(); | ||
| 27 | 24 | ||
| 25 | public abstract void run(); | ||
| 26 | |||
| 28 | private Future isRunning = null; | 27 | private Future isRunning = null; |
| 29 | public void activate(EventCallTime calltime) | 28 | public void activate(EventCallTime calltime) |
| 30 | { | 29 | { |
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 43cf626..faa7a48 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java | |||
| @@ -14,8 +14,6 @@ import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.FixedViewpoint; | |||
| 14 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint; | 14 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint; |
| 15 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; | 15 | import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; |
| 16 | import java.util.concurrent.CountDownLatch; | 16 | import java.util.concurrent.CountDownLatch; |
| 17 | import java.util.logging.Level; | ||
| 18 | import java.util.logging.Logger; | ||
| 19 | 17 | ||
| 20 | /** | 18 | /** |
| 21 | * | 19 | * |
| @@ -128,8 +126,9 @@ public class SpecialEvent { | |||
| 128 | 126 | ||
| 129 | /** | 127 | /** |
| 130 | * Waits until all previously called MoveEvent()s have finished | 128 | * Waits until all previously called MoveEvent()s have finished |
| 129 | * @throws InterruptedException | ||
| 131 | */ | 130 | */ |
| 132 | public void MoveEventWait() | 131 | public void MoveEventWait() throws InterruptedException |
| 133 | { | 132 | { |
| 134 | MoveEventThread.moveAll(); | 133 | MoveEventThread.moveAll(); |
| 135 | } | 134 | } |
| @@ -166,14 +165,11 @@ public class SpecialEvent { | |||
| 166 | * Waits for a specified interval | 165 | * Waits for a specified interval |
| 167 | * | 166 | * |
| 168 | * @param wait The time to wait in milliseconds | 167 | * @param wait The time to wait in milliseconds |
| 168 | * @throws InterruptedException | ||
| 169 | */ | 169 | */ |
| 170 | public void Wait(int wait) | 170 | public void Wait(int wait) throws InterruptedException |
| 171 | { | 171 | { |
| 172 | try { | 172 | Thread.sleep(wait); |
| 173 | Thread.sleep(wait); | ||
| 174 | } catch (InterruptedException ex) { | ||
| 175 | Logger.getLogger(SpecialEvent.class.getName()).log(Level.SEVERE, null, ex); | ||
| 176 | } | ||
| 177 | } | 173 | } |
| 178 | 174 | ||
| 179 | /** | 175 | /** |
| @@ -193,8 +189,9 @@ public class SpecialEvent { | |||
| 193 | * @param length How long (in milliseconds) it will take to pan | 189 | * @param length How long (in milliseconds) it will take to pan |
| 194 | * @param block If true, the game will wait for the pan to complete | 190 | * @param block If true, the game will wait for the pan to complete |
| 195 | * before executing any more commands | 191 | * before executing any more commands |
| 192 | * @throws InterruptedException | ||
| 196 | */ | 193 | */ |
| 197 | public void PanViewpoint(final int x, final int y, int length, final boolean block) | 194 | public void PanViewpoint(final int x, final int y, int length, final boolean block) throws InterruptedException |
| 198 | { | 195 | { |
| 199 | Viewpoint viewpoint = mapView.getViewpoint(); | 196 | Viewpoint viewpoint = mapView.getViewpoint(); |
| 200 | final CountDownLatch blocker; | 197 | final CountDownLatch blocker; |
| @@ -220,11 +217,7 @@ public class SpecialEvent { | |||
| 220 | 217 | ||
| 221 | if (block) | 218 | if (block) |
| 222 | { | 219 | { |
| 223 | try { | 220 | blocker.await(); |
| 224 | blocker.await(); | ||
| 225 | } catch (InterruptedException ex) { | ||
| 226 | Logger.getLogger(SpecialEvent.class.getName()).log(Level.SEVERE, null, ex); | ||
| 227 | } | ||
| 228 | } | 221 | } |
| 229 | } | 222 | } |
| 230 | 223 | ||
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java index 2395dd0..d129303 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java | |||
| @@ -11,8 +11,6 @@ import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; | |||
| 11 | import java.util.List; | 11 | import java.util.List; |
| 12 | import java.util.Vector; | 12 | import java.util.Vector; |
| 13 | import java.util.concurrent.Semaphore; | 13 | import java.util.concurrent.Semaphore; |
| 14 | import java.util.logging.Level; | ||
| 15 | import java.util.logging.Logger; | ||
| 16 | 14 | ||
| 17 | /** | 15 | /** |
| 18 | * | 16 | * |
| @@ -37,7 +35,7 @@ public class MoveEventThread implements Runnable { | |||
| 37 | try { | 35 | try { |
| 38 | moveEventWait.acquire(); | 36 | moveEventWait.acquire(); |
| 39 | } catch (InterruptedException ex) { | 37 | } catch (InterruptedException ex) { |
| 40 | Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); | 38 | Thread.currentThread().interrupt(); |
| 41 | } | 39 | } |
| 42 | 40 | ||
| 43 | while (ev.isMoving()) | 41 | while (ev.isMoving()) |
| @@ -45,7 +43,7 @@ public class MoveEventThread implements Runnable { | |||
| 45 | try { | 43 | try { |
| 46 | Thread.sleep(2); | 44 | Thread.sleep(2); |
| 47 | } catch (InterruptedException ex) { | 45 | } catch (InterruptedException ex) { |
| 48 | Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); | 46 | Thread.currentThread().interrupt(); |
| 49 | } | 47 | } |
| 50 | } | 48 | } |
| 51 | 49 | ||
| @@ -74,14 +72,10 @@ public class MoveEventThread implements Runnable { | |||
| 74 | return (events.contains(event)); | 72 | return (events.contains(event)); |
| 75 | } | 73 | } |
| 76 | 74 | ||
| 77 | public static void moveAll() | 75 | public static void moveAll() throws InterruptedException |
| 78 | { | 76 | { |
| 79 | try { | 77 | moveEventWait.acquire(100); |
| 80 | moveEventWait.acquire(100); | 78 | moveEventWait.release(100); |
| 81 | moveEventWait.release(100); | ||
| 82 | } catch (InterruptedException ex) { | ||
| 83 | Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); | ||
| 84 | } | ||
| 85 | } | 79 | } |
| 86 | 80 | ||
| 87 | } | 81 | } |
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java index d5d830e..af50087 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java | |||
| @@ -7,8 +7,6 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove; | |||
| 7 | 7 | ||
| 8 | import com.fourisland.fourpuzzle.Direction; | 8 | import com.fourisland.fourpuzzle.Direction; |
| 9 | import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; | 9 | import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; |
| 10 | import java.util.logging.Level; | ||
| 11 | import java.util.logging.Logger; | ||
| 12 | 10 | ||
| 13 | /** | 11 | /** |
| 14 | * StepMoveEvent moves the event in the direction specified. | 12 | * StepMoveEvent moves the event in the direction specified. |
| @@ -32,7 +30,7 @@ public class StepMoveEvent implements MoveEvent { | |||
| 32 | try { | 30 | try { |
| 33 | Thread.sleep(2); | 31 | Thread.sleep(2); |
| 34 | } catch (InterruptedException ex) { | 32 | } catch (InterruptedException ex) { |
| 35 | Logger.getLogger(StepMoveEvent.class.getName()).log(Level.SEVERE, null, ex); | 33 | Thread.currentThread().interrupt(); |
| 36 | } | 34 | } |
| 37 | } | 35 | } |
| 38 | } | 36 | } |
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/WaitMoveEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/WaitMoveEvent.java index eb56b95..565365a 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/WaitMoveEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/WaitMoveEvent.java | |||
| @@ -6,8 +6,6 @@ | |||
| 6 | package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove; | 6 | package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove; |
| 7 | 7 | ||
| 8 | import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; | 8 | import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; |
| 9 | import java.util.logging.Level; | ||
| 10 | import java.util.logging.Logger; | ||
| 11 | 9 | ||
| 12 | /** | 10 | /** |
| 13 | * WaitMoveEvent pauses for the specifed amount of milliseconds. | 11 | * WaitMoveEvent pauses for the specifed amount of milliseconds. |
| @@ -27,7 +25,7 @@ public class WaitMoveEvent implements MoveEvent { | |||
| 27 | try { | 25 | try { |
| 28 | Thread.sleep(wait); | 26 | Thread.sleep(wait); |
| 29 | } catch (InterruptedException ex) { | 27 | } catch (InterruptedException ex) { |
| 30 | Logger.getLogger(WaitMoveEvent.class.getName()).log(Level.SEVERE, null, ex); | 28 | Thread.currentThread().interrupt(); |
| 31 | } | 29 | } |
| 32 | } | 30 | } |
| 33 | 31 | ||
| diff --git a/src/com/fourisland/fourpuzzle/transition/TransitionCallbackThread.java b/src/com/fourisland/fourpuzzle/transition/TransitionCallbackThread.java index 58ea0b5..50eacc2 100644 --- a/src/com/fourisland/fourpuzzle/transition/TransitionCallbackThread.java +++ b/src/com/fourisland/fourpuzzle/transition/TransitionCallbackThread.java | |||
| @@ -6,8 +6,6 @@ | |||
| 6 | package com.fourisland.fourpuzzle.transition; | 6 | package com.fourisland.fourpuzzle.transition; |
| 7 | 7 | ||
| 8 | import com.fourisland.fourpuzzle.Display; | 8 | import com.fourisland.fourpuzzle.Display; |
| 9 | import java.util.logging.Level; | ||
| 10 | import java.util.logging.Logger; | ||
| 11 | 9 | ||
| 12 | /** | 10 | /** |
| 13 | * | 11 | * |
| @@ -28,7 +26,7 @@ public class TransitionCallbackThread implements Runnable { | |||
| 28 | try { | 26 | try { |
| 29 | Thread.sleep(300); | 27 | Thread.sleep(300); |
| 30 | } catch (InterruptedException ex) { | 28 | } catch (InterruptedException ex) { |
| 31 | Logger.getLogger(TransitionCallbackThread.class.getName()).log(Level.SEVERE, null, ex); | 29 | Thread.currentThread().interrupt(); |
| 32 | } | 30 | } |
| 33 | } | 31 | } |
| 34 | 32 | ||
