CVS update: JGroups/src/org/jgroups/protocols UFC.java

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

  Modified:    src/org/jgroups/protocols UFC.java
  Log:
  ns
  
  Revision  Changes    Path
  1.2       +4 -20     JGroups/src/org/jgroups/protocols/UFC.java
  
  Index: UFC.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/protocols/UFC.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UFC.java	31 Aug 2010 12:21:54 -0000	1.1
  +++ UFC.java	7 Sep 2010 10:38:21 -0000	1.2
  @@ -24,7 +24,7 @@
    * <li>Receivers don't send the full credits (max_credits), but rather the actual number of bytes received
    * <ol/>
    * @author Bela Ban
  - * @version $Id: UFC.java,v 1.1 2010/08/31 12:21:54 belaban Exp $
  + * @version $Id: UFC.java,v 1.2 2010/09/07 10:38:21 belaban Exp $
    */
   @MBean(description="Simple flow control protocol based on a credit system")
   public class UFC extends FlowControl {
  @@ -75,6 +75,7 @@
           super.stop();
           for(final Credit cred: sent.values()) {
               synchronized(cred) {
  +                cred.set(max_credits);
                   cred.notifyAll();
               }
           }
  @@ -96,40 +97,23 @@
               return down_prot.down(evt);
           }
   
  -        if(max_block_times != null) {
  -            long tmp=getMaxBlockTime(length);
  -            if(tmp > 0)
  -                end_time.set(System.currentTimeMillis() + tmp);
  -        }
  -
           UfcCredit cred=(UfcCredit)sent.get(dest);
           if(cred == null) {
               log.error("destination " + dest + " not found; passing message down");
               return down_prot.down(evt);
           }
   
  +        long block_time=max_block_times != null? getMaxBlockTime(length) : max_block_time;
  +        
           while(running) {
               if(cred.decrementIfEnoughCredits(length, 0)) // timeout == 0: don't block
                   break;
   
  -            long start_blocking=System.currentTimeMillis();
  -            long block_time=max_block_time;
  -            if(max_block_times != null) {
  -                Long tmp=end_time.get();
  -                if(tmp != null) {
  -                    // A negative block_time means we don't wait at all ! If the end_time already elapsed
  -                    // (because we waited for other threads to get processed), the message will not
  -                    // block at all and get sent immediately
  -                    block_time=tmp - start_blocking;
  -                }
  -            }
  -
               if(log.isTraceEnabled())
                   log.trace("blocking for credits (for " + block_time + " ms)");
               boolean rc=cred.decrementIfEnoughCredits(length, block_time);
               if(rc && log.isTraceEnabled())
                   log.trace("unblocking (received credits)");
  -            last_blockings.add(System.currentTimeMillis() - start_blocking);
               
               if(rc || !running || max_block_times != null)
                   break;
  
  
  

------------------------------------------------------------------------------
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.