示例#1
0
 /*public boolean deleteTick(TickActer E)
 {
 	//TockClient equiv=new TockClient(E, 0);
 	for(Iterator<Tick> e=ticks.iterator();e.hasNext();)
 	{
 		if(e.next().delTicker(E))
 			return true;
 	}
 	return false;
 }*/
 public boolean deleteArea(Tickable E) {
   TickArea almostTock = null;
   Iterator set = null;
   for (Iterator<TickArea> e = areaGroups(); e.hasNext(); ) {
     almostTock = e.next();
     if (almostTock.clientObject == E) {
       delArea(almostTock);
       almostTock.dead = true;
       if (Thread.currentThread() != almostTock) almostTock.shutdown();
       return true;
     }
   }
   return false;
 }
示例#2
0
 /*public int numTickGroups()
 {
 	return ticks.size();
 }*/
 public String[][] threadInfo() {
   ArrayList<String[]> V = new ArrayList();
   for (Iterator<CMLibrary> e = CMLib.libraries(); e.hasNext(); ) {
     CMLibrary lib = e.next();
     SupportThread thread = lib.getSupportThread();
     if (thread != null) {
       String[] S = new String[3];
       S[0] = thread.getName();
       S[1] = CMLib.english().returnTime(thread.milliTotal, thread.tickTotal);
       S[2] = thread.status;
       V.add(S);
     }
   }
   return V.toArray(new String[V.size()][]);
 }
示例#3
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) {
   }
 }
示例#4
0
  /*
  	public void insertOrderDeathInOrder(DVector DV, long lastStart, String msg, Tick tock)
  	{
  		if(DV.size()>0)
  		for(int i=0;i<DV.size();i++)
  		{
  			if(((Long)DV.elementAt(i,0)).longValue()>lastStart)
  			{
  				DV.insertRowAt(i,Long.valueOf(lastStart),msg,tock);
  				return;
  			}
  		}
  		DV.addRow(Long.valueOf(lastStart),msg,tock);
  	}
  */
  public void checkHealth() {
    long lastDateTime = System.currentTimeMillis() - (5 * CoffeeTime.MILI_MINUTE);
    // long longerDateTime=System.currentTimeMillis()-(120*CoffeeTime.MILI_MINUTE);
    // thread.status("checking");

    ArrayList<TickArea> orderedDeaths = new ArrayList();
    thread.status("checking tick groups.");
    /*for(Iterator<Tick> e=ticks.iterator();e.hasNext();)
    {
    	Tick almostTock=e.next();
    	if((almostTock.awake)
    	&&(almostTock.lastStop<lastDateTime))
    	{
    		//insertOrderDeathInOrder(orderedDeaths,0,"LOCKED GROUP "+almostTock.tickObjectCounter+"! No further information.",almostTock);
    		delTickGroup(almostTock);
    		orderedDeaths.add(almostTock);	//"LOCKED GROUP "+almostTock.tickObjectCounter+"! No further information."
    		// no isDEBUGGING check -- just always let her rip.
    		Log.errOut(thread.getName(),"LOCKED TICK GROUP "+almostTock.tickObjectCounter);
    		thread.debugDumpStack(almostTock);
    	}
    }
    if(orderedDeaths.size()>0)
    {
    	thread.status("killing tick groups.");
    	for(int x=0;x<orderedDeaths.size();x++)
    	{
    		Tick almostTock=orderedDeaths.get(x);
    		ArrayList<TickActer> objs=new ArrayList();
    		try{
    			for(TickActer E : almostTock.tickers())
    				objs.add(E);
    		}catch(NoSuchElementException e){}
    		almostTock.shutdown();
    		//if(CMLib.threads() instanceof ServiceEngine)
    		//	((ServiceEngine)CMLib.threads()).
    		//delTickGroup(almostTock);
    		for(int i=0;i<objs.size();i++)
    			startTickDown(objs.get(i));
    	}
    	orderedDeaths.clear();
    }*/
    thread.status("checking areas.");
    for (Iterator<TickArea> e = areas.iterator(); e.hasNext(); ) {
      TickArea almostTock = e.next();
      if ((almostTock.awake) && (almostTock.lastStop < lastDateTime)) {
        delArea(almostTock);
        // orderedDeaths.add(almostTock);	//"LOCKED GROUP "+almostTock.tickObjectCounter+"! No
        // further information."
        almostTock.shutdown();
        Log.errOut(thread.getName(), "LOCKED TICK GROUP " + almostTock.tickObjectCounter);
        thread.debugDumpStack(almostTock);
        startArea(almostTock.clientObject, almostTock.TICK_TIME);
      }
    }
    /*
    		thread.status("Checking mud threads");
    		for(int m=0;m<CMLib.hosts().size();m++)
    		{
    			Vector badThreads=((MudHost)CMLib.hosts().elementAt(m)).getOverdueThreads();
    			if(badThreads.size()>0)
    			{
    				for(int b=0;b<badThreads.size();b++)
    				{
    					Thread T=(Thread)badThreads.elementAt(b);
    					String threadName=T.getName();
    					if(T instanceof Tickable)
    						threadName=((Tickable)T).ID()+" ("+((Tickable)T).ID()+"): "+((Tickable)T).getTickStatus();
    					thread.status("Killing "+threadName);
    					Log.errOut("Killing stray thread: "+threadName);
    					CMLib.killThread(T,100,1);
    				}
    			}
    		}
    		thread.status("Done checking threads");
    */
  }