- Timestamp:
- 07/16/13 23:31:35 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/core/AbstractTree.java
r101 r102 34 34 import com.framsticks.util.dispatching.JoinableState; 35 35 import com.framsticks.util.dispatching.RunAt; 36 import com.framsticks.util.dispatching.Thread;37 36 import com.framsticks.util.dispatching.ThrowExceptionHandler; 38 37 import com.framsticks.util.lang.Pair; … … 42 41 */ 43 42 @FramsClassAnnotation 44 public abstract class AbstractTree extends AbstractJoinable implements Dispatcher<Tree>,Tree, JoinableParent, NeedFileAcceptor {43 public abstract class AbstractTree extends AbstractJoinable implements Tree, JoinableParent, NeedFileAcceptor { 45 44 46 45 private static final Logger log = LogManager.getLogger(AbstractTree.class); … … 49 48 private ExceptionResultHandler handler = ThrowExceptionHandler.getInstance(); 50 49 51 protected final BufferedDispatcher<Tree> bufferedDispatcher = new BufferedDispatcher<>( );50 protected final BufferedDispatcher<Tree> bufferedDispatcher = new BufferedDispatcher<>(this); 52 51 53 52 protected final PriorityQueue<Pair<Integer, NeedFileAcceptor>> needFileAcceptors = new PriorityQueue<>(32, new Comparator<Pair<Integer, NeedFileAcceptor>>() { … … 77 76 public void assignRootObject(Object object) { 78 77 if (root == null) { 79 throw new FramsticksException().msg("root ishas no type specified");78 throw new FramsticksException().msg("root has no type specified"); 80 79 } 81 80 if (root.getObject() != null) { … … 89 88 public @Nonnull Node getAssignedRoot() { 90 89 if (root == null) { 91 throw new FramsticksException().msg("root has no type specified yet") ;90 throw new FramsticksException().msg("root has no type specified yet").arg("in", this); 92 91 } 93 92 return root; … … 173 172 @Override 174 173 public Dispatcher<Tree> getDispatcher() { 175 return bufferedDispatcher .getTargetDispatcher();174 return bufferedDispatcher; 176 175 } 177 176 … … 181 180 @Override 182 181 public void setDispatcher(Dispatcher<Tree> dispatcher) { 183 if (bufferedDispatcher.getTargetDispatcher() != null) {184 throw new FramsticksException().msg("dispatcher is already set").arg("tree", this).arg("dispatcher", bufferedDispatcher.getTargetDispatcher());185 }186 182 bufferedDispatcher.setTargetDispatcher(dispatcher); 187 183 } … … 213 209 @Override 214 210 protected void joinableStart() { 215 if (bufferedDispatcher.getTargetDispatcher() == null) { 216 bufferedDispatcher.setTargetDispatcher(new Thread<Tree>()); 217 } 218 Dispatching.use(bufferedDispatcher.getTargetDispatcher(), this); 211 bufferedDispatcher.createThreadIfNeeded(); 212 Dispatching.use(bufferedDispatcher, this); 219 213 } 220 214 221 215 @Override 222 216 protected void joinableInterrupt() { 223 Dispatching.drop(bufferedDispatcher .getTargetDispatcher(), this);217 Dispatching.drop(bufferedDispatcher, this); 224 218 } 225 219 … … 231 225 @Override 232 226 protected void joinableJoin() throws InterruptedException { 233 Dispatching.join(bufferedDispatcher .getTargetDispatcher());227 Dispatching.join(bufferedDispatcher); 234 228 } 235 229 236 230 @Override 237 231 public void childChangedState(Joinable joinable, JoinableState state) { 238 if (joinable == bufferedDispatcher .getTargetDispatcher()) {232 if (joinable == bufferedDispatcher) { 239 233 proceedToState(state); 240 234 } … … 333 327 } 334 328 } 335 throw new FramsticksException().msg("failed to find need file acceptor in tree").arg("tree", AbstractTree.this) ;329 throw new FramsticksException().msg("failed to find need file acceptor in tree").arg("tree", AbstractTree.this).arg("needfile", needFile); 336 330 } 337 331 });
Note: See TracChangeset
for help on using the changeset viewer.