Agent Mailbox
A typed mailbox that holds AgentMessage values for a single AgentLike owner.
This is a POJO inner class — not a ModelElement, not backed by a BlockingQueue. Storage is a plain ArrayDeque; suspending receives use ksl.modeling.entity.ProcessModel.Entity.Suspension directly, which is KSL's per-entity custom-suspension primitive. This means a mailbox can be constructed at any time (notably, when its owning Agent is created during a replication).
Per-mailbox queue statistics are not collected. If you need them, register a Response/TWResponse observer at setup time via PermanentAgent and update it from your own send/receive call sites.
The mailbox is unbounded: deliver never blocks. Capacity-based back-pressure can be added later if needed.
Types
A scoped capture of messages matching predicate. While active, a matching message delivered to this mailbox is routed into the reservation's private buffer with priority over waiters, the pending queue, and arrival listeners — so a reserved conversation (e.g. a Contract-Net round) is never seen or consumed by an unrelated receiver on the same mailbox (a statechart onMessage handler, another receiveMessage). Call release when done.
Properties
Number of currently-registered MailboxObservers (for diagnostics).
Functions
Register a MailboxObserver to receive notifications on every delivery and consumption.
Non-suspending message insertion. If a process is currently suspended in receiveMessage with a matching predicate, hand the message directly to that waiter and resume it. Otherwise queue the message in pending and fire any registered arrival listeners. Once the replication's events have ended (a message sent from replicationEnded()), nothing can be resumed: the message is queued, and no waiter or arrival listener is offered it.
Remove a previously-attached MailboxObserver. No-op if not attached.
A trigger for a message on this mailbox that matches predicate, for use in a wait for the first of several things (waitForFirst). The trigger fires when a matching message is delivered while the wait is open, or at once if one is already waiting in the mailbox; its value is the message, which is taken from the mailbox. While the wait is open, its waiter takes its place among this mailbox's waiting receivers in the order it was registered, as a receiveMessage waiter does.
A trigger for a message of type T on this mailbox that also matches predicate. See trigger; the trigger's value is the message, typed as T.