Avoid allocating a wrapper for a runnable every time an actor is scheduled
This commit is contained in:
parent
90147b4970
commit
e483a57df9
|
@ -13,10 +13,10 @@ import java.util.logging.Logger;
|
|||
/**
|
||||
* I represent the shared execution concepts for a collection of objects; I am roughly analogous to the E concept of a Vat.
|
||||
*/
|
||||
public class Actor {
|
||||
public class Actor extends ForkJoinTask<Void> {
|
||||
private final static AtomicLong _count = new AtomicLong(0);
|
||||
private final static AtomicLong _actorId = new AtomicLong(0);
|
||||
protected final static ExecutorService _executor = new ForkJoinPool(
|
||||
protected final static ForkJoinPool _executor = new ForkJoinPool(
|
||||
Runtime.getRuntime().availableProcessors(),
|
||||
ForkJoinPool.defaultForkJoinWorkerThreadFactory,
|
||||
null,
|
||||
|
@ -212,12 +212,14 @@ public class Actor {
|
|||
}
|
||||
}
|
||||
|
||||
private Runnable __runWorkItems = this::_runWorkItems;
|
||||
public final Void getRawResult() { return null; }
|
||||
public final void setRawResult(Void v) { }
|
||||
public final boolean exec() { this._runWorkItems(); return false; }
|
||||
|
||||
public void execute(WorkItem item) {
|
||||
tail.getAndSet(item).set(item);
|
||||
if (workItemCount.getAndIncrement() == 0) {
|
||||
_executor.execute(__runWorkItems);
|
||||
_executor.execute(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue