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

## Class MonotonicityAwareMailbox

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

- All Implemented Interfaces:
    Mailbox, Clearable

      public class MonotonicityAwareMailbox
      extends java.lang.Object
      implements Mailbox

  A monotonicity aware mailbox implementation. The mailbox uses an `IPosetComparator` to identify if a pair of REVOKE - INSERT updates represent a monotone change pair. The mailbox is used by `MonotonicityAwareReceiver`s.
  Since:
    1.6

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `MonotonicityAwareMailbox.MessageIndexer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected MonotonicityAwareMailbox.MessageIndexer` | `antiMonotoneBuffer`
    `protected MonotonicityAwareMailbox.MessageIndexer` | `antiMonotoneQueue`
    `protected ReteContainer` | `container`
    `protected boolean` | `deliveringAntiMonotone`
    `protected boolean` | `deliveringMonotone`
    `protected TupleMask` | `groupMask`
    `protected MonotonicityAwareMailbox.MessageIndexer` | `monotoneBuffer`
    `protected MonotonicityAwareMailbox.MessageIndexer` | `monotoneQueue`
    `protected MonotonicityAwareReceiver` | `receiver`
    `protected CommunicationTracker` | `tracker`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MonotonicityAwareMailbox(MonotonicityAwareReceiver 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 MonotonicityAwareMailbox.MessageIndexer` | `getActiveAntiMonotoneQueue()`
    `protected MonotonicityAwareMailbox.MessageIndexer` | `getActiveMonotoneQueue()`
    `Receiver` | `getReceiver()` Returns the `Receiver` of this mailbox.
    `void` | `postMessage(Direction direction, Tuple update)` Posts a new message to this mailbox.
    `java.lang.String` | `toString()`
    `protected java.util.Set<Tuple>` | `tryFindCounterPart(Tuple first, boolean findPositiveCounterPart, boolean findAllCounterParts)`

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

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

- - ### Field Detail

    - #### monotoneQueue

          protected MonotonicityAwareMailbox.MessageIndexer monotoneQueue

    - #### antiMonotoneQueue

          protected MonotonicityAwareMailbox.MessageIndexer antiMonotoneQueue

    - #### monotoneBuffer

          protected MonotonicityAwareMailbox.MessageIndexer monotoneBuffer

    - #### antiMonotoneBuffer

          protected MonotonicityAwareMailbox.MessageIndexer antiMonotoneBuffer

    - #### deliveringMonotone

          protected boolean deliveringMonotone

    - #### deliveringAntiMonotone

          protected boolean deliveringAntiMonotone

    - #### receiver

          protected final MonotonicityAwareReceiver receiver

    - #### container

          protected final ReteContainer container

    - #### tracker

          protected final CommunicationTracker tracker

    - #### groupMask

          protected final TupleMask groupMask

  - ### Constructor Detail

    - #### MonotonicityAwareMailbox

          public MonotonicityAwareMailbox(MonotonicityAwareReceiver receiver,
                                          ReteContainer container)

  - ### Method Detail

    - #### getActiveMonotoneQueue

          protected MonotonicityAwareMailbox.MessageIndexer getActiveMonotoneQueue()

    - #### getActiveAntiMonotoneQueue

          protected MonotonicityAwareMailbox.MessageIndexer getActiveAntiMonotoneQueue()

    - #### 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

    - #### tryFindCounterPart

          protected java.util.Set<Tuple> tryFindCounterPart(Tuple first,
                                                            boolean findPositiveCounterPart,
                                                            boolean findAllCounterParts)

    - #### 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`