Rearrange daemonization
This commit is contained in:
parent
882b47602d
commit
9c7b71fa51
|
@ -96,9 +96,8 @@ public class Actor {
|
||||||
return _alive && !_isCounted;
|
return _alive && !_isCounted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Actor daemonize() {
|
public void daemonize() {
|
||||||
this._releaseCount();
|
this.scheduleTurn(_t -> this._releaseCount());
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _releaseCount() {
|
private void _releaseCount() {
|
||||||
|
@ -138,8 +137,9 @@ public class Actor {
|
||||||
return new Ref(this, o);
|
return new Ref(this, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scheduleTurn(Consumer<Turn> f) {
|
public Actor scheduleTurn(Consumer<Turn> f) {
|
||||||
this.execute(new WorkItem(f, null));
|
this.execute(new WorkItem(f, null));
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _performTurn(Consumer<Turn> f) {
|
void _performTurn(Consumer<Turn> f) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.syndicate_lang.actors.Turn;
|
||||||
public class Main extends Entity {
|
public class Main extends Entity {
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
Actor.convenientLogging();
|
Actor.convenientLogging();
|
||||||
new Actor().daemonize().scheduleTurn(t -> {
|
new Actor().scheduleTurn(t -> {
|
||||||
final var vh = Actor.forEntity(new ValueHolder<>("There"));
|
final var vh = Actor.forEntity(new ValueHolder<>("There"));
|
||||||
vh.getActor().daemonize();
|
vh.getActor().daemonize();
|
||||||
final var m = Actor.boot(u -> {
|
final var m = Actor.boot(u -> {
|
||||||
|
@ -29,7 +29,7 @@ public class Main extends Entity {
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
});
|
}).daemonize();
|
||||||
|
|
||||||
Actor.awaitAll();
|
Actor.awaitAll();
|
||||||
System.out.println("Overall main returning");
|
System.out.println("Overall main returning");
|
||||||
|
|
|
@ -13,7 +13,9 @@ import static java.lang.Integer.parseInt;
|
||||||
public class Main extends Entity {
|
public class Main extends Entity {
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
Actor.convenientLogging();
|
Actor.convenientLogging();
|
||||||
new Actor().daemonize().scheduleTurn(t -> new Main(parseInt(args[0]), parseInt(args[1])).boot(t));
|
new Actor()
|
||||||
|
.scheduleTurn(t -> new Main(parseInt(args[0]), parseInt(args[1])).boot(t))
|
||||||
|
.daemonize();
|
||||||
Actor.awaitAll();
|
Actor.awaitAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue