예제 #1
0
 public void heartbeat(long delta) {
   if (engine != null) {
     TickStage.checkStage(TickStage.TICKSTART);
   } else {
     TickStage.checkStage(TickStage.STAGE1);
   }
   SpoutRegion region;
   SpoutTask task;
   while ((task = newTasks.poll()) != null) {
     int taskId = task.getTaskId();
     ParallelTaskInfo info = activeTasks.get(taskId);
     if (info == null) {
       info = new ParallelTaskInfo(task);
       ParallelTaskInfo previous = activeTasks.putIfAbsent(taskId, info);
       if (previous != null) {
         info = previous;
       }
       task.setParallelInfo(info);
     }
     Collection<? extends World> worlds = (this.world == null) ? engine.getWorlds() : world;
     for (World w : worlds) {
       SpoutWorld sw = (SpoutWorld) w;
       for (Region r : sw.getRegions()) {
         info.add((SpoutRegion) r);
       }
     }
   }
   while ((region = newRegions.poll()) != null) {
     for (ParallelTaskInfo info : activeTasks.values(ParallelTaskInfo.EMPTY_ARRAY)) {
       info.add(region);
     }
   }
   while ((region = deadRegions.poll()) != null) {
     while (newRegions.remove(region)) {;
     }
     for (ParallelTaskInfo info : activeTasks.values(ParallelTaskInfo.EMPTY_ARRAY)) {
       while (info.remove(region)) {;
       }
     }
   }
 }
예제 #2
0
 private void checkStages() {
   this.regionThread = region.getExecutionThread();
   TickStage.checkStage(globalStages, localStages, regionThread);
 }
예제 #3
0
 public void unRegisterRegion(SpoutRegion r) {
   TickStage.checkStage(TickStage.SNAPSHOT);
   deadRegions.add(r);
 }