org.eclipse.viatra.query.runtime.rete.network

## Class DefaultMailbox

- java.lang.Object
- - org.eclipse.viatra.query.runtime.rete.network.DefaultMailbox

- All Implemented Interfaces:
    Mailbox, Clearable

      public class DefaultMailbox
      extends java.lang.Object
      implements Mailbox

  Default mailbox implementation.

  Usually, the mailbox performs counting of messages so that they can cancel each other out. However, if marked as a fall-through mailbox, than update messages are delivered directly to the receiver node to reduce overhead.

  Since:
    1.6

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Map<Tuple,java.lang.Integer>` | `buffer`
    `protected ReteContainer` | `container`
    `protected boolean` | `delivering`
    `protected boolean` | `fallThrough`
    `protected java.util.Map<Tuple,java.lang.Integer>` | `queue`
    `protected Receiver` | `receiver`
    `protected CommunicationTracker` | `tracker`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultMailbox()`
    `DefaultMailbox(Receiver receiver, ReteContainer container)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clear all partial matchings stored in memory
    `void` | `deliverAll(MessageKind kind)` Delivers all messages of the given kind from this mailbox.
    `protected java.lang.Integer` | `get(Tuple key)`
    `protected java.util.Map<Tuple,java.lang.Integer>` | `getActiveQueue()`
    `Receiver` | `getReceiver()` Returns the `Receiver` of this mailbox.
    `protected boolean` | `isEmpty()`
    `boolean` | `isFallThrough()`
    `protected java.util.Set<Tuple>` | `keySet()`
    `void` | `postMessage(Direction direction, Tuple update)` Posts a new message to this mailbox.
    `void` | `setFallThrough(boolean fallThrough)` Controlled by the `CommunicationTracker` which can determine based on node type and network topology whether fall-through is allowed.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### queue

          protected java.util.Map<Tuple,java.lang.Integer> queue

    - #### buffer

          protected java.util.Map<Tuple,java.lang.Integer> buffer

    - #### receiver

          protected final Receiver receiver

    - #### container

          protected final ReteContainer container

    - #### delivering

          protected boolean delivering

    - #### tracker

          protected final CommunicationTracker tracker

    - #### fallThrough

          protected boolean fallThrough

  - ### Constructor Detail

    - #### DefaultMailbox

          public DefaultMailbox()

    - #### DefaultMailbox

          public DefaultMailbox(Receiver receiver,
                                ReteContainer container)

  - ### Method Detail

    - #### getActiveQueue

          protected java.util.Map<Tuple,java.lang.Integer> getActiveQueue()

    - #### get

          protected java.lang.Integer get(Tuple key)

    - #### isEmpty

          protected boolean isEmpty()

    - #### keySet

          protected java.util.Set<Tuple> keySet()

    - #### postMessage

          public void postMessage(Direction direction,
                                  Tuple update)

      Description copied from interface: `Mailbox`
      Posts a new message to this mailbox.
      Specified by:
        `postMessage` in interface `Mailbox`
      Parameters:
        `direction` - the direction of the update
        `update` - the update element

    - #### deliverAll

          public void deliverAll(MessageKind kind)

      Description copied from interface: `Mailbox`
      Delivers all messages of the given kind from this mailbox. The kind can also be null. In this case, there no special separation is expected between the messages.
      Specified by:
        `deliverAll` in interface `Mailbox`
      Parameters:
        `kind` - the message kind

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getReceiver

          public Receiver getReceiver()

      Description copied from interface: `Mailbox`
      Returns the `Receiver` of this mailbox.
      Specified by:
        `getReceiver` in interface `Mailbox`
      Returns:
        the receiver

    - #### clear

          public void clear()

      Description copied from interface: `Clearable`
      Clear all partial matchings stored in memory
      Specified by:
        `clear` in interface `Clearable`

    - #### isFallThrough

          public boolean isFallThrough()

    - #### setFallThrough

          public void setFallThrough(boolean fallThrough)

      Controlled by the `CommunicationTracker` which can determine based on node type and network topology whether fall-through is allowed.