- Timestamp:
- 07/08/13 23:04:56 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/util/dispatching/Dispatching.java
r97 r98 86 86 87 87 public static void childChangedState(final JoinableParent parent, final Joinable joinable, final JoinableState state) { 88 if (state.ordinal() <= JoinableState.RUNNING.ordinal()) { 89 return; 90 } 88 91 dispatcherGuardedInvoke(joinable, new RunAt<Object>(ThrowExceptionHandler.getInstance()) { 89 92 @Override … … 118 121 } 119 122 120 public interface Query<T> {123 public interface Query<T> extends ExceptionResultHandler { 121 124 T get(); 125 } 126 127 public static abstract class QueryHandler<T> implements Query<T> { 128 ExceptionResultHandler handler; 129 130 /** 131 * @param handler 132 */ 133 public QueryHandler(ExceptionResultHandler handler) { 134 this.handler = handler; 135 } 136 137 @Override 138 public void handle(FramsticksException exception) { 139 handler.handle(exception); 140 } 122 141 } 123 142 … … 131 150 */ 132 151 public QueryRunner(Query<T> query) { 133 //TODO TEH 134 super(ThrowExceptionHandler.getInstance()); 152 super(query); 135 153 this.query = query; 136 154 } … … 164 182 } 165 183 184 public static class DispatcherWaiter<C, T extends Dispatcher<C> & Joinable> implements Dispatcher<C> { 185 // protected boolean done = false; 186 protected final T dispatcher; 187 protected RunAt<? extends C> runnable; 188 189 /** 190 * @param joinable 191 */ 192 public DispatcherWaiter(T dispatcher) { 193 this.dispatcher = dispatcher; 194 } 195 196 public synchronized void waitFor() { 197 while ((runnable == null) && (dispatcher.getState().ordinal() <= JoinableState.RUNNING.ordinal())) { 198 try { 199 this.wait(); 200 } catch (InterruptedException e) { 201 } 202 } 203 if (runnable != null) { 204 runnable.run(); 205 } 206 207 } 208 209 @Override 210 public boolean isActive() { 211 return dispatcher.isActive(); 212 } 213 214 @Override 215 public synchronized void dispatch(RunAt<? extends C> runnable) { 216 this.runnable = runnable; 217 this.notifyAll(); 218 } 219 220 } 221 166 222 public static class Waiter { 167 223 protected boolean done = false;
Note: See TracChangeset
for help on using the changeset viewer.