/** * Returns the next message from the mailbox. If no message is currently available, this method blocks until a message arrives. * * @return a message sent to this actor. * @throws InterruptedException */ @Override public final Message receive() throws SuspendExecution, InterruptedException { try { for (;;) { checkThrownIn0(); record(1, "Actor", "receive", "%s waiting for a message", this); final Object m = mailbox().receive(); record(1, "Actor", "receive", "Received %s <- %s", this, m); if (Debug.isDebug() && flightRecorder != null && flightRecorder.get().recordsLevel(2)) record(2, "Actor", "receive", "%s queue %s", this, getQueueLength()); monitorAddMessage(); Message msg = filterMessage(m); if (msg != null) return msg; } } catch (InterruptedException e) { checkThrownIn0(); throw e; } }
@Override protected final boolean trySend(Message message) { record(1, "Actor", "trySend", "Sending %s -> %s", message, this); if (Debug.isDebug() && flightRecorder != null && flightRecorder.get().recordsLevel(2)) record(2, "Actor", "trySend", "%s queue %s", this, getQueueLength()); if (mailbox().isOwnerAlive()) { if (mailbox().trySend(message)) return true; record(1, "Actor", "trySend", "Message not sent. Mailbox is not ready."); return false; } record(1, "Actor", "trySend", "Message dropped. Owner not alive."); return true; }
@Override protected final void sendSync(Message message) throws SuspendExecution { record(1, "Actor", "sendSync", "Sending sync %s -> %s", message, this); if (Debug.isDebug() && flightRecorder != null && flightRecorder.get().recordsLevel(2)) record(2, "Actor", "sendSync", "%s queue %s", this, getQueueLength()); if (mailbox().isOwnerAlive()) mailbox().sendSync(message); else record(1, "Actor", "sendSync", "Message dropped. Owner not alive."); }
protected final boolean isRecordingLevel(int level) { if (!Debug.isDebug()) return false; final FlightRecorder.ThreadRecorder recorder = flightRecorder != null ? flightRecorder.get() : null; if (recorder == null) return false; return recorder.recordsLevel(level); }
protected final boolean isRecordingLevel(int level) { if (flightRecorder == null) return false; final FlightRecorder.ThreadRecorder recorder = flightRecorder.get(); if (recorder == null) return false; return recorder.recordsLevel(level); }
@Override protected void internalSendNonSuspendable(Object message) { record(1, "Actor", "send", "Sending %s -> %s", message, this); if (Debug.isDebug() && flightRecorder != null && flightRecorder.get().recordsLevel(2)) record(2, "Actor", "send", "%s queue %s", this, getQueueLength()); if (mailbox().isOwnerAlive()) mailbox().sendNonSuspendable(message); else record(1, "Actor", "send", "Message dropped. Owner not alive."); }