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

io.magentys.FutureMission Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package io.magentys;

import java.util.concurrent.CompletableFuture;

public interface FutureMission extends Mission{

    default public CompletableFuture accomplishAsync(Mission mission, FunctionalAgent agent) {
            CompletableFuture futureResult = new CompletableFuture<>();
            Runnable runnable = () -> {
                try {
                    Result result = mission.accomplishAs(agent);
                    futureResult.complete(result);
                } catch (Throwable e) {
                    futureResult.completeExceptionally(e);
                }
            };
            new Thread(runnable).start();
            return futureResult;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy