/** * The given consumer is invoked with each registered handler instance. * <p> * Exceptions raised by the invocation of the consumer for a particular * handler are printed to the console and the current thread's * uncaught exception handler is notified. * <p> * This method is threadsafe. * @param consumer the consumer to invoke */ public final void forEach(@NonNull Consumer<H> consumer) { ObjectHelper.requireNonNull(consumer, "consumer is null"); Iterator<HandlerRegistration<H>> it = handlers.iterator(); while (it.hasNext()) { try { HandlerRegistration<H> hr = it.next(); H h = hr.get(); if (h != null) { consumer.accept(h); } } catch (Throwable ex) { ex.printStackTrace(); Thread t = Thread.currentThread(); t.getUncaughtExceptionHandler().uncaughtException(t, ex); } } }
/** * The given consumer is invoked with each registered handler instance. * <p> * Exceptions raised by the invocation of the consumer for a particular * handler are printed to the console and the current thread's * uncaught exception handler is notified. * <p> * This method is threadsafe. * @param consumer the consumer to invoke */ public final void forEach(@NonNull Consumer<H> consumer) { ObjectHelper.requireNonNull(consumer, "consumer is null"); Iterator<HandlerRegistration<H>> it = handlers.iterator(); while (it.hasNext()) { try { HandlerRegistration<H> hr = it.next(); H h = hr.get(); if (h != null) { consumer.accept(h); } } catch (Throwable ex) { ex.printStackTrace(); Thread t = Thread.currentThread(); t.getUncaughtExceptionHandler().uncaughtException(t, ex); } } }
/** * The given consumer is invoked with each registered handler instance. * <p> * Exceptions raised by the invocation of the consumer for a particular * handler are printed to the console and the current thread's * uncaught exception handler is notified. * <p> * This method is threadsafe. * @param <S> the type of the extra state provided to the consumer * @param state the extra state provided to the consumer * @param consumer the consumer to invoke */ public final <S> void forEach(S state, @NonNull BiConsumer<S, H> consumer) { ObjectHelper.requireNonNull(consumer, "consumer is null"); Iterator<HandlerRegistration<H>> it = handlers.iterator(); while (it.hasNext()) { try { HandlerRegistration<H> hr = it.next(); H h = hr.get(); if (h != null) { consumer.accept(state, h); } } catch (Throwable ex) { ex.printStackTrace(); Thread t = Thread.currentThread(); t.getUncaughtExceptionHandler().uncaughtException(t, ex); } } }
/** * The given consumer is invoked with each registered handler instance. * <p> * Exceptions raised by the invocation of the consumer for a particular * handler are printed to the console and the current thread's * uncaught exception handler is notified. * <p> * This method is threadsafe. * @param <S> the type of the extra state provided to the consumer * @param state the extra state provided to the consumer * @param consumer the consumer to invoke */ public final <S> void forEach(S state, @NonNull BiConsumer<S, H> consumer) { ObjectHelper.requireNonNull(consumer, "consumer is null"); Iterator<HandlerRegistration<H>> it = handlers.iterator(); while (it.hasNext()) { try { HandlerRegistration<H> hr = it.next(); H h = hr.get(); if (h != null) { consumer.accept(state, h); } } catch (Throwable ex) { ex.printStackTrace(); Thread t = Thread.currentThread(); t.getUncaughtExceptionHandler().uncaughtException(t, ex); } } }
@Override public boolean isDisposed() { return get() == null; } }
@Override public boolean isDisposed() { return get() == null; } }