Package org.jgroups.util
Class Credit
- java.lang.Object
-
- org.jgroups.util.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 Summary
Fields Modifier and Type Field Description protected Average
avg_blockings
protected java.util.concurrent.locks.Condition
credits_available
protected long
credits_left
protected boolean
done
protected long
last_credit_request
protected java.util.concurrent.locks.Lock
lock
protected int
num_blockings
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
decrement(long credits)
long
decrementAndGet(long credits, long min_credits, long max_credits)
boolean
decrementIfEnoughCredits(Message msg, int credits, long timeout)
long
get()
double
getAverageBlockTime()
int
getNumBlockings()
void
increment(long credits, long max_credits)
boolean
needToSendCreditRequest(long max_block_time)
Credit
reset()
Sets this credit to be done and releases all blocked threads.void
resetStats()
java.lang.String
toString()
-
-
-
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
-
-
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 classjava.lang.Object
-
decrement
protected boolean decrement(long credits)
-
-