diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java | 2 | ||||
| -rwxr-xr-x | src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java | 22 |
2 files changed, 21 insertions, 3 deletions
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java index f577cc2..7214528 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java | |||
| @@ -11,7 +11,7 @@ import java.util.concurrent.Future; | |||
| 11 | * | 11 | * |
| 12 | * @author hatkirby | 12 | * @author hatkirby |
| 13 | */ | 13 | */ |
| 14 | public abstract class EventCall extends SpecialEvent implements Runnable { | 14 | public abstract class EventCall extends SpecialEvent { |
| 15 | 15 | ||
| 16 | public static EventCall getEmptyEventCall() | 16 | public static EventCall getEmptyEventCall() |
| 17 | { | 17 | { |
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java index 05997e0..a8a626f 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventHandler.java | |||
| @@ -5,6 +5,8 @@ | |||
| 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.PuzzleApplication; | ||
| 9 | import com.fourisland.fourpuzzle.util.ResourceNotFoundException; | ||
| 8 | import java.util.concurrent.ExecutorService; | 10 | import java.util.concurrent.ExecutorService; |
| 9 | import java.util.concurrent.Executors; | 11 | import java.util.concurrent.Executors; |
| 10 | import java.util.concurrent.Future; | 12 | import java.util.concurrent.Future; |
| @@ -32,13 +34,29 @@ public class EventHandler { | |||
| 32 | 34 | ||
| 33 | public static Future runEvent(EventCall callback) | 35 | public static Future runEvent(EventCall callback) |
| 34 | { | 36 | { |
| 35 | eventAction = eventExecutorService.submit(callback); | 37 | eventAction = eventExecutorService.submit(eventThread(callback)); |
| 36 | return eventAction; | 38 | return eventAction; |
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | public static Future runParallel(EventCall callback) | 41 | public static Future runParallel(EventCall callback) |
| 40 | { | 42 | { |
| 41 | return parallelExecutorService.submit(callback); | 43 | return parallelExecutorService.submit(eventThread(callback)); |
| 44 | } | ||
| 45 | |||
| 46 | private static Runnable eventThread(final EventCall callback) | ||
| 47 | { | ||
| 48 | return new Runnable() { | ||
| 49 | public void run() | ||
| 50 | { | ||
| 51 | try | ||
| 52 | { | ||
| 53 | callback.run(); | ||
| 54 | } catch (ResourceNotFoundException ex) | ||
| 55 | { | ||
| 56 | PuzzleApplication.INSTANCE.reportError(ex); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | }; | ||
| 42 | } | 60 | } |
| 43 | 61 | ||
| 44 | public static boolean isRunningEvent() | 62 | public static boolean isRunningEvent() |
