ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CyclicBarrier.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CyclicBarrier.java (file contents):
Revision 1.30 by dl, Thu Apr 21 23:56:09 2005 UTC vs.
Revision 1.31 by dl, Mon Apr 25 10:37:41 2005 UTC

# Line 85 | Line 85 | import java.util.concurrent.locks.*;
85   * point prematurely because of interruption, failure, or timeout, all
86   * other threads waiting at that barrier point will also leave
87   * abnormally via {@link BrokenBarrierException} (or
88 < * <tt>InterruptedException</tt> if they too were interrupted at about
88 > * {@link InterruptedException} if they too were interrupted at about
89   * the same time).
90   *
91   * @since 1.5
# Line 123 | Line 123 | public class CyclicBarrier {
123  
124      /**
125       * Number of parties still waiting. Counts down from parties to 0
126 <     * on each generation. This only has meaning for the current non-broken
127 <     * generation. It is reset to parties on each new generation.
126 >     * on each generation.  It is reset to parties on each new
127 >     * generation or when broken.
128       */
129      private int count;
130  
# Line 147 | Line 147 | public class CyclicBarrier {
147       */
148      private void breakBarrier() {
149          generation.broken = true;
150 +        count = parties;
151          trip.signalAll();
152      }
153  
# Line 173 | Line 174 | public class CyclicBarrier {
174             if (index == 0) {  // tripped
175                 boolean ranAction = false;
176                 try {
177 <                   if (barrierCommand != null)
178 <                       barrierCommand.run();
177 >                   final Runnable command = barrierCommand;
178 >                   if (command != null)
179 >                       command.run();
180                     ranAction = true;
181                     nextGeneration();
182                     return 0;
# Line 235 | Line 237 | public class CyclicBarrier {
237      /**
238       * Creates a new <tt>CyclicBarrier</tt> that will trip when the
239       * given number of parties (threads) are waiting upon it, and
240 <     * does not perform a predefined action upon each barrier.
240 >     * does not perform a predefined action when the barrier is tripped.
241       *
242       * @param parties the number of threads that must invoke {@link #await}
243       * before the barrier is tripped.
# Line 249 | Line 251 | public class CyclicBarrier {
251      /**
252       * Returns the number of parties required to trip this barrier.
253       * @return the number of parties required to trip this barrier.
254 <     **/
254 >     */
255      public int getParties() {
256          return parties;
257      }
# Line 432 | Line 434 | public class CyclicBarrier {
434          final ReentrantLock lock = this.lock;
435          lock.lock();
436          try {
437 <            return generation.broken ? 0 : parties - count;
437 >            return parties - count;
438          } finally {
439              lock.unlock();
440          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines