Class NonBlockingCredit


  • public class NonBlockingCredit
    extends Credit
    Non-blocking credit for a unicast destination.
    Instead of blocking when insufficient credits are available for sending a message, this class queues the message and sends it at a later time when enough credits have been received to send it.
    JIRA: https://issues.redhat.com/browse/JGRP-2172
    Since:
    4.0.4
    Author:
    Bela Ban
    • Field Detail

      • queuing

        protected boolean queuing
      • send_function

        protected final java.util.function.Consumer<Message> send_function
      • NO_OP_SEND_FUNCTION

        protected static final java.util.function.Consumer<Message> NO_OP_SEND_FUNCTION
      • num_queued

        protected final java.util.concurrent.atomic.LongAdder num_queued
    • Constructor Detail

      • NonBlockingCredit

        public NonBlockingCredit​(long credits,
                                 int max_size,
                                 java.util.concurrent.locks.Lock lock)
      • NonBlockingCredit

        public NonBlockingCredit​(long credits,
                                 int max_size,
                                 java.util.concurrent.locks.Lock lock,
                                 java.util.function.Consumer<Message> send_function)
    • Method Detail

      • isQueuing

        public boolean isQueuing()
      • getQueuedMessages

        public int getQueuedMessages()
      • getQueuedMessageSize

        public int getQueuedMessageSize()
      • getEnqueuedMessages

        public int getEnqueuedMessages()
      • decrementIfEnoughCredits

        public boolean decrementIfEnoughCredits​(Message msg,
                                                int credits,
                                                long timeout)
        Decrements the sender's credits by the size of the message.
        Overrides:
        decrementIfEnoughCredits in class Credit
        Parameters:
        msg - The message
        credits - The number of bytes to decrement the credits. Is Message.getLength().
        timeout - Ignored
        Returns:
        True if the message was sent, false if it was queued
      • increment

        public void increment​(long credits,
                              long max_credits)
        Overrides:
        increment in class Credit
      • reset

        public Credit reset()
        Description copied from class: Credit
        Sets this credit to be done and releases all blocked threads. This is not revertable; a new credit has to be created
        Overrides:
        reset in class Credit
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Credit
      • addToQueue

        protected boolean addToQueue​(Message msg,
                                     int length)