Class NonBlockingCreditMap


  • public class NonBlockingCreditMap
    extends CreditMap
    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

      • NonBlockingCreditMap

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

        public NonBlockingCreditMap​(long max_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()
      • decrement

        public boolean decrement​(Message msg,
                                 int credits,
                                 long timeout)
        Description copied from class: CreditMap
        Decrements credits bytes from all. Returns true if successful, or false if not. Blocks for timeout ms (if greater than 0).
        Overrides:
        decrement in class CreditMap
        Parameters:
        msg - The message to be sent
        credits - Number of bytes to decrement from all members
        timeout - Number of milliseconds to wait until more credits have been received
        Returns:
        True if decrementing credits bytes succeeded, false otherwise
      • reset

        public CreditMap reset()
        Description copied from class: CreditMap
        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 CreditMap
      • toString

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

        protected boolean addToQueue​(Message msg,
                                     int length)