@Override public boolean contains(final Tickable T, final int tickID) { if (tickID >= 0) return tickers.contains(new StdTickClient(T, 0, tickID)); return tickers .subSet( new StdTickClient(T, 0, -1), true, new StdTickClient(T, 0, Integer.MAX_VALUE), true) .size() > 0; }
@Override public Iterator<TickClient> getTickSet(final Tickable T, final int tickID) { final LinkedList<TickClient> subSet = new LinkedList<TickClient>(); if (tickID < 0) subSet.addAll( tickers.subSet( new StdTickClient(T, 0, 0), true, new StdTickClient(T, 0, Integer.MAX_VALUE), true)); else subSet.addAll( tickers.subSet( new StdTickClient(T, 0, tickID), true, new StdTickClient(T, 0, tickID), true)); return subSet.iterator(); }
@Override public void run() { nextTickTime = System.currentTimeMillis() + tickTime; // final String oldThreadName=Thread.currentThread().getName(); try { currentThread = Thread.currentThread(); lastStart = System.currentTimeMillis(); lastClient = null; final boolean allSuspended = CMLib.threads().isAllSuspended(); if ((CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) && (!allSuspended)) { for (final Iterator<TickClient> i = tickers(); i.hasNext(); ) { final TickClient client = i.next(); lastClient = client; // if(client.getCurrentTickDown()<=1) // currentThread.setName(oldThreadName+":"+getName()+":"+client.getName()); if (client.tickTicker(false)) { delTicker(client); // cant do i.remove, its an streeset } } } } finally { lastStop = System.currentTimeMillis(); milliTotal += (lastStop - lastStart); tickTotal++; currentThread = null; // Thread.currentThread().setName(oldThreadName); } if (tickers.size() == 0) { if (CMLib.threads() instanceof ServiceEngine) ((ServiceEngine) CMLib.threads()).delTickGroup(this); } }
@Override public void shutdown() { tickers.clear(); if (CMLib.threads() instanceof ServiceEngine) ((ServiceEngine) CMLib.threads()).delTickGroup(this); }
@Override public void addTicker(TickClient C) { if (!tickers.contains(C)) tickers.add(C); }
@Override public void delTicker(TickClient C) { tickers.remove(C); }
@Override public int numTickers() { return tickers.size(); }
@Override public Iterator<TickClient> tickers() { return tickers.iterator(); }