Пример #1
0
  @Override
  public void backgroundProcess() {
    // This method gets called once a second.
    backgroundProcessCount++;

    if (backgroundProcessCount >= processPeriod) {
      backgroundProcessCount = 0;

      long now = System.currentTimeMillis();
      Iterator<WsRemoteEndpointImplServer> iter = endpoints.iterator();
      while (iter.hasNext()) {
        WsRemoteEndpointImplServer endpoint = iter.next();
        if (endpoint.getTimeoutExpiry() < now) {
          // Background thread, not the thread that triggered the
          // write so no need to use a dispatch
          endpoint.onTimeout(false);
        } else {
          // Endpoints are ordered by timeout expiry so if this point
          // is reached there is no need to check the remaining
          // endpoints
          break;
        }
      }
    }
  }
Пример #2
0
    @Override
    public int compare(WsRemoteEndpointImplServer o1, WsRemoteEndpointImplServer o2) {

      long t1 = o1.getTimeoutExpiry();
      long t2 = o2.getTimeoutExpiry();

      if (t1 < t2) {
        return -1;
      } else if (t1 == t2) {
        return 0;
      } else {
        return 1;
      }
    }