Reduce API surface of Actor by avoiding subclassing
This commit is contained in:
parent
0835077035
commit
1d744181ec
|
@ -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.
|
* 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 _count = new AtomicLong(0);
|
||||||
private final static AtomicLong _actorId = new AtomicLong(0);
|
private final static AtomicLong _actorId = new AtomicLong(0);
|
||||||
protected final static ForkJoinPool _executor = new ForkJoinPool(
|
protected final static ForkJoinPool _executor = new ForkJoinPool(
|
||||||
|
@ -206,14 +206,21 @@ public class Actor extends ForkJoinTask<Void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public final Void getRawResult() { return null; }
|
private static final class Task extends ForkJoinTask<Void> {
|
||||||
@Override public final void setRawResult(Void v) { }
|
private Actor _actor;
|
||||||
@Override public final boolean exec() { this._runWorkItems(); return false; }
|
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) {
|
public void execute(WorkItem item) {
|
||||||
tail.getAndSet(item).set(item);
|
tail.getAndSet(item).set(item);
|
||||||
if (workItemCount.getAndIncrement() == 0) {
|
if (workItemCount.getAndIncrement() == 0) {
|
||||||
_executor.execute(this);
|
_executor.execute(this._task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue