Is there *really* a need to allocate fresh Turns every time? I think not
This commit is contained in:
parent
732bb0066d
commit
636da3f28f
|
@ -20,6 +20,7 @@ public class Actor implements Executor {
|
|||
|
||||
private final String _name;
|
||||
private final Logger _logger;
|
||||
final Turn _turn = new Turn(this);
|
||||
|
||||
private boolean _alive = true;
|
||||
private Throwable _exitReason = null;
|
||||
|
|
|
@ -9,7 +9,6 @@ public class Turn {
|
|||
private final static AtomicLong nextHandle = new AtomicLong(0);
|
||||
|
||||
private final Actor _actor;
|
||||
private boolean _complete = false;
|
||||
|
||||
private Actor _pendingTarget = null;
|
||||
private Consumer<Turn> _pending0 = null;
|
||||
|
@ -22,7 +21,7 @@ public class Turn {
|
|||
}
|
||||
|
||||
static void _forActor(Actor a, Consumer<Turn> f) {
|
||||
Turn t = new Turn(a);
|
||||
Turn t = a._turn;
|
||||
try {
|
||||
f.accept(t);
|
||||
t.commit();
|
||||
|
@ -31,7 +30,7 @@ public class Turn {
|
|||
}
|
||||
}
|
||||
|
||||
private Turn(Actor a) {
|
||||
Turn(Actor a) {
|
||||
this._actor = a;
|
||||
}
|
||||
|
||||
|
@ -58,11 +57,9 @@ public class Turn {
|
|||
if (q2 != null) q2.accept(t);
|
||||
}));
|
||||
}
|
||||
_complete = true;
|
||||
}
|
||||
|
||||
private void enqueue(Actor target, Consumer<Turn> action) {
|
||||
if (_complete) throw new IllegalStateException("Attempt to reuse a committed Turn");
|
||||
if (_pending == null) {
|
||||
if (_pendingTarget == null) {
|
||||
_pendingTarget = target;
|
||||
|
@ -85,11 +82,6 @@ public class Turn {
|
|||
_pending.computeIfAbsent(target, k -> new LinkedList<>()).add(action);
|
||||
}
|
||||
|
||||
public void freshen(Consumer<Turn> action) {
|
||||
if (!_complete) throw new IllegalStateException(("Attempt to freshen a non-stale Turn"));
|
||||
Turn.forActor(this._actor, action);
|
||||
}
|
||||
|
||||
public Ref ref(IEntity o) {
|
||||
return _actor.ref(o);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue