All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.yudichev.jiotty.common.lang.DispatchingConflatingRunnable Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package net.yudichev.jiotty.common.lang;

import java.util.concurrent.Executor;

public final class DispatchingConflatingRunnable implements Runnable {
    private static final Object VALUE = new Object();
    private final DispatchingConflatingConsumer conflatingConsumer;

    public DispatchingConflatingRunnable(Executor executor, Runnable delegate) {
        conflatingConsumer = new DispatchingConflatingConsumer<>(executor, supplier -> {
            supplier.get();
            delegate.run();
        });
    }

    @Override
    public void run() {
        conflatingConsumer.accept(VALUE);
    }
}