ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166y/ForkJoinTask.java
(Generate patch)

Comparing jsr166/src/jsr166y/ForkJoinTask.java (file contents):
Revision 1.71 by dl, Tue Nov 23 10:51:18 2010 UTC vs.
Revision 1.72 by dl, Wed Nov 24 10:50:38 2010 UTC

# Line 238 | Line 238 | public abstract class ForkJoinTask<V> im
238       * only by pool.
239       */
240      final void internalAwaitDone(long millis, int nanos) {
241 <        if (status >= 0) {
241 >        int s = status;
242 >        if ((s == 0 &&
243 >             UNSAFE.compareAndSwapInt(this, statusOffset, 0, SIGNAL)) ||
244 >            s > 0)  {
245              try {     // the odd construction reduces lock bias effects
246                  synchronized (this) {
247 <                    if (status > 0 ||
245 <                        UNSAFE.compareAndSwapInt(this, statusOffset,
246 <                                                 0, SIGNAL))
247 >                    if (status > 0)
248                          wait(millis, nanos);
249 +                    else
250 +                        notifyAll();
251                  }
252              } catch (InterruptedException ie) {
253                  cancelIfTerminating();
# Line 259 | Line 262 | public abstract class ForkJoinTask<V> im
262          if (status >= 0) {
263              boolean interrupted = false;
264              synchronized(this) {
265 <                int s;
266 <                while ((s = status) >= 0) {
267 <                    if (s == 0 &&
268 <                        !UNSAFE.compareAndSwapInt(this, statusOffset,
269 <                                                  0, SIGNAL))
270 <                        continue;
271 <                    try {
272 <                        wait();
273 <                    } catch (InterruptedException ie) {
274 <                        interrupted = true;
265 >                for (;;) {
266 >                    int s = status;
267 >                    if (s == 0)
268 >                        UNSAFE.compareAndSwapInt(this, statusOffset,
269 >                                                 0, SIGNAL);
270 >                    else if (s < 0) {
271 >                        notifyAll();
272 >                        break;
273 >                    }
274 >                    else {
275 >                        try {
276 >                            wait();
277 >                        } catch (InterruptedException ie) {
278 >                            interrupted = true;
279 >                        }
280                      }
281                  }
282              }
# Line 287 | Line 295 | public abstract class ForkJoinTask<V> im
295          if (status >= 0) {
296              long startTime = timed ? System.nanoTime() : 0L;
297              synchronized(this) {
298 <                int s;
291 <                while ((s = status) >= 0) {
298 >                for (;;) {
299                      long nt;
300 <                    if (s == 0 &&
301 <                        !UNSAFE.compareAndSwapInt(this, statusOffset,
302 <                                                  0, SIGNAL))
303 <                        continue;
300 >                    int s = status;
301 >                    if (s == 0)
302 >                        UNSAFE.compareAndSwapInt(this, statusOffset,
303 >                                                 0, SIGNAL);
304 >                    else if (s < 0) {
305 >                        notifyAll();
306 >                        break;
307 >                    }
308                      else if (!timed)
309                          wait();
310                      else if ((nt = nanos - (System.nanoTime()-startTime)) > 0L)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines