예제 #1
0
 public void run() {
   long nextStart = System.currentTimeMillis();
   try {
     while (!dead) {
       long timeToSleep = nextStart - System.currentTimeMillis();
       if (timeToSleep > 10) Thread.sleep(timeToSleep);
       nextStart += Tickable.TIME_TICK;
       if ((CMProps.Bools.MUDSTARTED.property()) && (!CMLib.threads().isAllSuspended())) {
         globalTickCount++;
         for (Iterator<Exit> iter = exits.iterator(); iter.hasNext(); ) {
           Exit exit = iter.next();
           try {
             if (!exit.tick(globalTickCount)) exits.remove(exit);
           } catch (Exception e) {
             Log.errOut("ServiceEngine", e.toString());
           }
         }
         for (Iterator<TimeClock> iter = clocks.iterator(); iter.hasNext(); ) {
           TimeClock clock = iter.next();
           try {
             if (!clock.tick(globalTickCount)) clocks.remove(clock);
           } catch (Exception e) {
             Log.errOut("ServiceEngine", e.toString());
           }
         }
       }
     }
   } catch (InterruptedException e) {
   }
 }
예제 #2
0
 public void run() {
   while (true) {
     try {
       while (!tickActQueue.isEmpty()) {
         awake = false;
         TickActer next = tickActQueue.first();
         long timeToSleep = next.nextAct() - System.currentTimeMillis();
         if (timeToSleep > 0) Thread.sleep(timeToSleep);
         awake = true;
         nextTicker:
         if ((CMProps.Bools.MUDSTARTED.property()) && (!isSuspended)) {
           if (!tickActQueue.remove(next)) break nextTicker;
           CMClass.threadPool.execute(next);
         }
       }
     }
     /*try { next.tickAct(); }
     catch(Exception t) { Log.errOut("ServiceEngine",t); }*/
     catch (InterruptedException ioe) {
     }
     // If it was interrupted, it is most likely because we need to wake up for a new early
     // ticker, or the previous new ticker got baleeted.
     // Interruptions will only come if the thread is sleeping though.
     // NOTE: tickAct() should NEVER call a sleep (nor take any significant amount of time
     // anyways)!
     if (dead) {
       awake = false;
       break;
     }
     synchronized (tickActQueue) {
       while (tickActQueue.isEmpty())
         try {
           tickActQueue.wait();
         } catch (InterruptedException ioe) {
         }
     }
   }
 }