class BatchRequestService extends AbstractIdleService {

  public <T> void add(AsyncRequest<T> request) throws InterruptedException {
    checkNotNull(request, "can not batch null request");
    checkState(isRunning(), "can not batch elements if service is not running.");
    requests.put(request);
    boolean flushed = flushIfRequired();
    if (!flushed && needToScheduleFlush.get()) {
      scheduleAutoFlush();
    }
  }

  public  BatchRequestService(Builder builder);

}