Spaces:
Build error
Build error
package net.minecraft.util.thread; | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.Executor; | |
import java.util.function.Consumer; | |
public interface TaskScheduler<R extends Runnable> extends AutoCloseable { | |
String name(); | |
void schedule(R p_365586_); | |
default void close() { | |
} | |
R wrapRunnable(Runnable p_367607_); | |
default <Source> CompletableFuture<Source> scheduleWithResult(Consumer<CompletableFuture<Source>> p_365778_) { | |
CompletableFuture<Source> completablefuture = new CompletableFuture<>(); | |
this.schedule(this.wrapRunnable(() -> p_365778_.accept(completablefuture))); | |
return completablefuture; | |
} | |
static TaskScheduler<Runnable> wrapExecutor(final String p_367076_, final Executor p_363384_) { | |
return new TaskScheduler<Runnable>() { | |
public String name() { | |
return p_367076_; | |
} | |
public void schedule(Runnable p_361412_) { | |
p_363384_.execute(p_361412_); | |
} | |
public Runnable wrapRunnable(Runnable p_367104_) { | |
return p_367104_; | |
} | |
public String toString() { | |
return p_367076_; | |
} | |
}; | |
} | |
} |