Compare commits

...

2 Commits

1 changed files with 13 additions and 6 deletions

View File

@ -13,7 +13,7 @@ import java.util.logging.Logger;
/**
* I represent the shared execution context for a collection of objects; I am roughly analogous to the E concept of a Vat.
*/
public class Actor extends ForkJoinTask<Void> {
public class Actor {
private final static AtomicLong _count = new AtomicLong(0);
private final static AtomicLong _actorId = new AtomicLong(0);
protected final static ForkJoinPool _executor = new ForkJoinPool(
@ -133,7 +133,7 @@ public class Actor extends ForkJoinTask<Void> {
return super.toString() + "(" + this._name + ")";
}
public<T> Ref ref(IEntity o) {
public Ref ref(IEntity o) {
return new Ref(this, o);
}
@ -206,14 +206,21 @@ public class Actor extends ForkJoinTask<Void> {
}
}
@Override public final Void getRawResult() { return null; }
@Override public final void setRawResult(Void v) { }
@Override public final boolean exec() { this._runWorkItems(); return false; }
private static final class Task extends ForkJoinTask<Void> {
private Actor _actor;
Task(Actor a) {
this._actor = a;
}
@Override public final Void getRawResult() { return null; }
@Override public final void setRawResult(Void v) { }
@Override public final boolean exec() { _actor._runWorkItems(); return false; }
};
private Task _task = new Task(this);
public void execute(WorkItem item) {
tail.getAndSet(item).set(item);
if (workItemCount.getAndIncrement() == 0) {
_executor.execute(this);
_executor.execute(this._task);
}
}