eu.lucaventuri.fibry.Spawner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fibry Show documentation
Show all versions of fibry Show documentation
The first Java Actor System supporting fibers from Project Loom
package eu.lucaventuri.fibry;
import eu.lucaventuri.common.CountingExitable;
import eu.lucaventuri.common.Exitable;
import java.util.function.Consumer;
import java.util.function.Function;
/** Class able to create new actors with a predefined logic */
class Spawner extends CountingExitable {
private final Function logic;
private final ActorSystem.NamedStateActorCreator creator;
private Consumer finalizer = state -> addFinished();
Spawner(ActorSystem.NamedStateActorCreator creator, Function logic) {
this.logic = logic;
this.creator=creator;
}
public Actor spawn() {
addCreated();
return creator.newActorWithReturn(logic);
}
public Consumer finalizer() {
return finalizer;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy