Esempio n. 1
0
  /**
   * Creates a new instance.
   *
   * @param timer the {@link Timer} that is used to trigger the scheduled event. The recommended
   *     {@link Timer} implementation is {@link HashedWheelTimer}.
   * @param timeout read timeout
   * @param unit the {@link TimeUnit} of {@code timeout}
   */
  public ReadTimeoutHandler(Timer timer, long timeout, TimeUnit unit) {
    if (timer == null) {
      throw new NullPointerException("timer");
    }
    if (unit == null) {
      throw new NullPointerException("unit");
    }

    this.timer = timer;
    if (timeout <= 0) {
      timeoutMillis = 0;
    } else {
      timeoutMillis = Math.max(unit.toMillis(timeout), 1);
    }
  }
Esempio n. 2
0
 NioDatagramWorker nextWorker() {
   return workers[Math.abs(workerIndex.getAndIncrement() % workers.length)];
 }