CVS update: JGroups/src/org/jgroups/util CreditMap.java

"Bela Ban" <[email protected]>
Newsgroups gmane.comp.java.javagroups.cvs
Message-ID <[email protected]>
  User: belaban 
  Date: 10/09/09 11:34:46

  Modified:    src/org/jgroups/util CreditMap.java
  Log:
  first draft of separate impls for unicast (UFC) and multicast (MFC) flow control (https://jira.jboss.org/browse/JGRP-1154)
  
  Revision  Changes    Path
  1.9       +19 -2     JGroups/src/org/jgroups/util/CreditMap.java
  
  Index: CreditMap.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/util/CreditMap.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CreditMap.java	8 Sep 2010 14:03:10 -0000	1.8
  +++ CreditMap.java	9 Sep 2010 11:34:45 -0000	1.9
  @@ -12,7 +12,7 @@
   /**
    * Maintains credits for senders, when credits fall below 0, a sender blocks until new credits have been received.
    * @author Bela Ban
  - * @version $Id: CreditMap.java,v 1.8 2010/09/08 14:03:10 belaban Exp $
  + * @version $Id: CreditMap.java,v 1.9 2010/09/09 11:34:45 belaban Exp $
    */
   public class CreditMap {
       protected final long              max_credits;
  @@ -23,6 +23,8 @@
       protected long                    accumulated_credits=0;
       protected final Lock              lock=new ReentrantLock();
       protected final Condition         credits_available=lock.newCondition();
  +    protected int                     num_blockings=0;
  +    protected long                    total_block_time=0;
   
   
       public CreditMap(long max_credits) {
  @@ -38,6 +40,14 @@
           return min_credits;
       }
   
  +    public int getNumBlockings() {
  +        return num_blockings;
  +    }
  +
  +    public long getTotalBlockTime() {
  +        return total_block_time;
  +    }
  +
       public Set<Address> keys() {
           lock.lock();
           try {
  @@ -124,9 +134,14 @@
   
               if(timeout <= 0)
                   return false;
  -            
  +
               try {
  +                num_blockings++;
  +                long start=System.currentTimeMillis();
                   credits_available.await(timeout, TimeUnit.MILLISECONDS);
  +                long diff=System.currentTimeMillis() - start;
  +                if(diff > 0)
  +                    total_block_time+=diff;
                   if(decrement(credits))
                       return true;
               }
  @@ -184,6 +199,8 @@
       public void clear() {
           lock.lock();
           try {
  +            num_blockings=0;
  +            total_block_time=0;
               credits.clear();
               credits_available.signalAll();
           }
  
  
  

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.