Update of /cvsroot/freenet/freenet/src/freenet/thread
In directory sc8-pr-cvs1:/tmp/cvs-serv27970

Modified Files:
        QThreadFactory.java 
Log Message:
Whitespace changes only.  Re-indented using this emacs command:

C-x ( C-a TAB C-n C-x ) C-u 9999 C-x e


Index: QThreadFactory.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/thread/QThreadFactory.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- QThreadFactory.java 28 Sep 2003 10:20:42 -0000      1.37
+++ QThreadFactory.java 28 Sep 2003 18:05:31 -0000      1.38
@@ -16,7 +16,7 @@
  * @author ejhuff
  */
 public final class QThreadFactory implements ThreadFactory, Runnable {
-
+       
     /** The absolute minimum amount of active threads to be available */
     public static final int MINIMUM_AVAILABLE_ABS = 3;
     /** The minimum ratio of the number of active threads to be available */
@@ -26,19 +26,19 @@
     /** The ideal ratio of the number of active threads to keep available */
     private static final double IDEAL_AVAILABLE_RATIO = 
         (2 * MINIMUM_AVAILABLE_RATIO + MAXIMUM_AVAILABLE_RATIO) / 3;
-
+       
     private final ThreadGroup tg;
-
+       
     private final CountLock countLock = new CountLock();
-
+       
     private final NumLock numLock = new NumLock();
-
+       
     private final HeadLock headLock = new HeadLock();
-
+       
        private final boolean logDEBUG;
-
+       
     private final MaxLock maxLock = new MaxLock();
-
+       
     /**
      * @param tg     ThreadGroup all created threads will belong to
      */
@@ -48,7 +48,7 @@
                this.logDEBUG = Core.logger.shouldLog(Logger.DEBUG, this);
         (new Thread(this, "Thread creation thread.")).start();
     }
-
+       
     public final void run() {
                CountSnap snap = new CountSnap();
         while (true) {
@@ -135,7 +135,7 @@
                        countLock.waitForNotify(1000); 
         }
     }
-
+       
     /**
      * @return  the target maximum executing jobs.
         *          Caller may use this, together with
@@ -146,7 +146,7 @@
     public final int maximumThreads() {
                return maxLock.desiredMax();
     }
-
+       
     /**
      * @return  the number of currently executing jobs
      */
@@ -155,7 +155,7 @@
                countLock.snap(snap);
         return snap.active;
     }
-
+       
     /**
      * @return  the instantaneous number of idle threads
      */
@@ -164,7 +164,7 @@
                countLock.snap(snap);
         return snap.available;
     }
-
+       
     /**
      * @param job       The job to be executed
         * @return the thread which was popped or created.
@@ -179,34 +179,34 @@
         thread.next = null;
         thread.job = job;
         thread.start();
-
+               
                countLock.mightNotify();
                return thread;
     }
-
+       
     private final class QThread extends Thread implements PooledThread {
-
+               
         private QThread next; // link for stack of available threads.
-    
+               
         private Runnable job = null;
-
+               
         private int jobsDone = 0;
-
+               
         private final Irreversible alive = new Irreversible(true);
-    
+               
         public QThread(long num) {
             super(tg, "QThread-"+num);
             super.start();
         }
-
+               
         public final Runnable job() {
             return job;
         }
-
+               
         public final synchronized void start() {
             this.notify();
         }
-
+               
         public final void run() {
             while (alive.state()) {
                 synchronized (this) {
@@ -242,9 +242,9 @@
                     }
                 }
             }
-
+                       
             Core.diagnostics.occurrenceContinuous("jobsPerQThread", jobsDone);
-
+                       
                        CountSnap snap = new CountSnap();
                        countLock.snap(snap);
                        if (logDEBUG)
@@ -253,7 +253,7 @@
                                                                snap.active + "threads 
active.",
                                                                Core.logger.DEBUG);
         }
-
+               
         /**
                 *  Called only from QThreadFactory.run() in this context:
                 *  if (countLock.snapTake(snap)) {
@@ -267,7 +267,7 @@
             }
         }
     }
-
+       
        private final class MaxLock {
                private int desiredMax;
                synchronized void setDesiredMax(int desiredMax) {
@@ -280,14 +280,14 @@
                        this.desiredMax = Math.max(this.desiredMax - decr, 0);
                }
        }
-
+       
     private final class NumLock {
                private int threadNumber = 0;
                synchronized int newThreadNumber() {
                        return threadNumber++;
                }
        }
-
+       
     private final class HeadLock {
                QThread headerThread = null;
                synchronized void push(QThread thread) {
@@ -300,30 +300,30 @@
                        return thread;
                }
        }
-
+       
        private final class CountSnap {
                int active = 0;
                int available = 0;
        }
-
+       
     private final class CountLock {
                private int active = 0;
                // available is always either the number of threads on 
headLock.headerThread,
                // or else one fewer, in the case where it has been decremented but the
                // thread hasn't been removed yet.
                private int available = 0;
-
+               
                synchronized void snap(CountSnap snap) {
                        snap.active = active;
                        snap.available = available;
                }
-
+               
                synchronized void snapFree(CountSnap snap) {
                        available++; // thread was already pushed onto stack.
                        snap.active = active;
                        snap.available = available;
                }
-
+               
                synchronized boolean snapTake(CountSnap snap) {
                        boolean gotOne = false;
                        if (available >= 1) { // There is at least one on stack.
@@ -334,7 +334,7 @@
                        snap.available = available;
                        return gotOne;
                }
-
+               
                // Before calling free, available is one too small
                // compared to the actual state of headLock.headerThread.
         // QThreadFactory.run() or getThread() could sneak in before this.
@@ -342,7 +342,7 @@
             active--;
             available++; // thread is already on the stack
                }
-
+               
                synchronized boolean makeItMyself() {
                        boolean makeItMyself = false;
             active++;
@@ -353,21 +353,21 @@
                        }
                        return makeItMyself;
                }
-
+               
         synchronized void mightNotify() { 
             if ( ( available < MINIMUM_AVAILABLE_ABS) ||
                  ( available < active * MINIMUM_AVAILABLE_RATIO) || 
                  ( ( available > (3 * MINIMUM_AVAILABLE_ABS)) &&
-                          ( available > active * MAXIMUM_AVAILABLE_RATIO))) {
+                                  ( available > active * MAXIMUM_AVAILABLE_RATIO))) {
                                this.notifyAll();
             }
         } 
-
+               
                synchronized void waitForNotify(int maxDelayMillis) {
                        try { 
                                this.wait(maxDelayMillis); 
                        } catch ( InterruptedException ie ) {}
                }
-
+               
        }
 }

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to