Remove IMonitorHandler
This commit is contained in:
parent
fb7e17b624
commit
9965027eb6
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -28,7 +29,7 @@ public class Actor implements Executor {
|
||||||
private Throwable _exitReason = null;
|
private Throwable _exitReason = null;
|
||||||
private boolean _isCounted = true;
|
private boolean _isCounted = true;
|
||||||
private Set<Actor> _links = null;
|
private Set<Actor> _links = null;
|
||||||
private Map<Object, Remote<IMonitorHandler>> _monitors = null;
|
private Map<Object, Remote<BiConsumer<Actor, Object>>> _monitors = null;
|
||||||
private Consumer<Actor> _exitTrap = null;
|
private Consumer<Actor> _exitTrap = null;
|
||||||
|
|
||||||
public static Actor current() {
|
public static Actor current() {
|
||||||
|
@ -103,7 +104,7 @@ public class Actor implements Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public<T> Remote<T> proxyFor(T o) {
|
public<T> Remote<T> proxyFor(T o) {
|
||||||
return new Remote<T>(this, o);
|
return new Remote<>(this, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _perform(Runnable work, Runnable ifNotAlive) {
|
private void _perform(Runnable work, Runnable ifNotAlive) {
|
||||||
|
@ -159,12 +160,12 @@ public class Actor implements Executor {
|
||||||
peer.notifyExit(this);
|
peer.notifyExit(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<Object, Remote<IMonitorHandler>> monitoringPeers = _monitors;
|
Map<Object, Remote<BiConsumer<Actor, Object>>> monitoringPeers = _monitors;
|
||||||
if (monitoringPeers != null) {
|
if (monitoringPeers != null) {
|
||||||
_monitors = null;
|
_monitors = null;
|
||||||
for (var entry : monitoringPeers.entrySet()) {
|
for (var entry : monitoringPeers.entrySet()) {
|
||||||
final var ref = entry.getKey();
|
final var ref = entry.getKey();
|
||||||
entry.getValue().async((h) -> h.handleMonitor(this, ref));
|
entry.getValue().async((h) -> h.accept(this, ref));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_releaseCount();
|
_releaseCount();
|
||||||
|
@ -273,12 +274,12 @@ public class Actor implements Executor {
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void monitor(final Object ref, IMonitorHandler handler) {
|
public synchronized void monitor(final Object ref, BiConsumer<Actor, Object> handler) {
|
||||||
if (this._alive) {
|
if (this._alive) {
|
||||||
if (_monitors == null) _monitors = new HashMap<>();
|
if (_monitors == null) _monitors = new HashMap<>();
|
||||||
_monitors.put(ref, Actor.ref(handler));
|
_monitors.put(ref, Actor.ref(handler));
|
||||||
} else {
|
} else {
|
||||||
Actor.ref(handler).async((h) -> h.handleMonitor(this, ref));
|
Actor.ref(handler).async((h) -> h.accept(this, ref));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package org.syndicate_lang.actors;
|
|
||||||
|
|
||||||
public interface IMonitorHandler {
|
|
||||||
void handleMonitor(Actor exitingPeer, Object ref);
|
|
||||||
}
|
|
Loading…
Reference in New Issue