Beispiel #1
0
  @Override
  void onKnown(URI uri, long[] ticks) {
    boolean all = false;
    long[] list = null;
    int count = 0;

    synchronized (this) {
      if (_ticks == null || _ticks.length == 0) all = true;
      else {
        for (int i = 0; i < ticks.length; i++) {
          if (!Tick.isNull(ticks[i])) {
            if (!Tick.contains(_ticks, ticks[i])) {
              if (list == null) list = new long[ticks.length];

              list[count++] = ticks[i];
            }
          }
        }
      }
    }

    if (all) {
      for (int i = 0; i < ticks.length; i++)
        if (!Tick.isNull(ticks[i])) uri.getBlock(this, ticks[i]);
    } else if (list != null) {
      for (int i = 0; i < count; i++) uri.getBlock(this, list[i]);
    }
  }
Beispiel #2
0
  public Tick getAvailTickThread(Tickable E, long TICK_TIME, int tickID) {
    Tick tock = null;
    Tick almostTock = null;
    ThreadGroup grp = null;
    char threadGroupNum = Thread.currentThread().getThreadGroup().getName().charAt(0);
    for (Iterator<Tick> e = tickGroups(); e.hasNext(); ) {
      almostTock = e.next();
      if (almostTock != null) {
        if (almostTock.contains(E, tickID)) return null;
        if ((tock == null)
            && (almostTock.TICK_TIME == TICK_TIME)
            && (!almostTock.solitaryTicker)
            && (almostTock.numTickers() < TickableGroup.MAX_TICK_CLIENTS)) {
          grp = almostTock.getThreadGroup();
          if ((grp != null) && (grp.getName().charAt(0) == threadGroupNum)) {
            tock = almostTock;
          }
        }
      }
    }

    if (tock != null) return tock;
    tock = new Tick(TICK_TIME);
    addTickGroup(tock);
    return tock;
  }