static boolean addThrowable()

in autodispose/src/main/java/autodispose2/ExceptionHelper.java [41:60]


  static boolean addThrowable(AtomicReference<Throwable> field, Throwable exception) {
    for (; ; ) {
      Throwable current = field.get();

      if (current == TERMINATED) {
        return false;
      }

      Throwable update;
      if (current == null) {
        update = exception;
      } else {
        update = new CompositeException(current, exception);
      }

      if (field.compareAndSet(current, update)) {
        return true;
      }
    }
  }