net.yudichev.jiotty.common.async.DispatchedConsumer Maven / Gradle / Ivy
package net.yudichev.jiotty.common.async;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import static com.google.common.base.Preconditions.checkNotNull;
public final class DispatchedConsumer implements Consumer {
private final Consumer delegate;
private final Executor executor;
public DispatchedConsumer(Consumer delegate, Executor executor) {
this.delegate = checkNotNull(delegate);
this.executor = checkNotNull(executor);
}
@Override
public void accept(T t) {
executor.execute(() -> delegate.accept(t));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy