Class Credit

  • Direct Known Subclasses:
    NonBlockingCredit

    public class Credit
    extends java.lang.Object
    Maintains credits for a unicast destination. Used by flow control.
    Since:
    4.0.4
    Author:
    Bela Ban
    • Field Detail

      • lock

        protected final java.util.concurrent.locks.Lock lock
      • credits_available

        protected final java.util.concurrent.locks.Condition credits_available
      • done

        protected boolean done
      • credits_left

        protected long credits_left
      • num_blockings

        protected int num_blockings
      • last_credit_request

        protected long last_credit_request
      • avg_blockings

        protected final Average avg_blockings
    • Constructor Detail

      • Credit

        public Credit​(long credits)
      • Credit

        public Credit​(long credits,
                      java.util.concurrent.locks.Lock lock)
    • Method Detail

      • getNumBlockings

        public int getNumBlockings()
      • get

        public long get()
      • getAverageBlockTime

        public double getAverageBlockTime()
      • resetStats

        public void resetStats()
      • decrementIfEnoughCredits

        public boolean decrementIfEnoughCredits​(Message msg,
                                                int credits,
                                                long timeout)
      • decrementAndGet

        public long decrementAndGet​(long credits,
                                    long min_credits,
                                    long max_credits)
      • increment

        public void increment​(long credits,
                              long max_credits)
      • reset

        public Credit reset()
        Sets this credit to be done and releases all blocked threads. This is not revertable; a new credit has to be created
      • needToSendCreditRequest

        public boolean needToSendCreditRequest​(long max_block_time)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • decrement

        protected boolean decrement​(long credits)