}
this.reactor.transcript.traceDebugging ("destroying proxy `%{object:identity}` (owned by actor `%{object:identity}`)...", this.proxy, this);
final Throwable failure = this.failed.get ();
if (failure == null) {
final ActorAssignAction assign = this.assignAction.get ();
final CallbackHandler handler = this.handler.get ();
if ((handler != null) && (assign == null)) {
final Scheduler scheduler = this.scheduler.get ();
Preconditions.checkState (scheduler != null);
this.reactor.transcript.traceDebugging ("invocking unregister callback on handler `%{object}` for proxy `%{object:identity}` (owned by actor `%{object:identity}`) backed by isolate `%{object:identity}` (owned by scheduler `%{object:identity}`)...", handler, this.proxy, this, scheduler.isolate, scheduler);
try {
handler.unregisteredCallbacks (this.specification.cast (this.proxy));
} catch (final Throwable exception) {
this.reactor.exceptions.traceDeferredException (exception);
this.triggerFailure (exception);
return;
}
scheduler.unregisterActor (this);
Preconditions.checkState (this.handler.compareAndSet (handler, null));
Preconditions.checkState (this.scheduler.compareAndSet (scheduler, null));
} else {
if (assign != null) {
assign.future.triggerFailure (new CallbackCanceled ());
Preconditions.checkState (this.assignAction.compareAndSet (assign, null));
}
for (final ActorAction<?> action : this.actions)
action.future.triggerFailure (new CallbackCanceled ());
this.actions.clear ();
}
} else {
final ActorAssignAction assign = this.assignAction.get ();
final CallbackHandler handler = this.handler.get ();
if (handler != null) {
final Scheduler scheduler = this.scheduler.get ();
Preconditions.checkState (scheduler != null);
this.reactor.transcript.traceDebugging ("invocking failure callback on handler `%{object}` for proxy `%{object:identity}` (owned by actor `%{object:identity}`) backed by isolate `%{object:identity}` (owned by scheduler `%{object:identity}`)...", handler, this.proxy, this, scheduler.isolate, scheduler);
// FIXME: This should be called only if we have successfully called `registeredCallbacks`
try {
handler.failedCallbacks (this.specification.cast (this.proxy), failure);
} catch (final Throwable exception) {
this.reactor.exceptions.traceIgnoredException (exception);
}
scheduler.unregisterActor (this);
Preconditions.checkState (this.handler.compareAndSet (handler, null));