equal
deleted
inserted
replaced
237 * heavily dependent on intrinsics (Unsafe) to use inlined |
237 * heavily dependent on intrinsics (Unsafe) to use inlined |
238 * embedded CAS and related memory access operations (that tend |
238 * embedded CAS and related memory access operations (that tend |
239 * not to be as readily inlined by dynamic compilers when they are |
239 * not to be as readily inlined by dynamic compilers when they are |
240 * hidden behind other methods that would more nicely name and |
240 * hidden behind other methods that would more nicely name and |
241 * encapsulate the intended effects). This includes the use of |
241 * encapsulate the intended effects). This includes the use of |
242 * putOrderedX to clear fields of the per-thread Nodes between |
242 * putXRelease to clear fields of the per-thread Nodes between |
243 * uses. Note that field Node.item is not declared as volatile |
243 * uses. Note that field Node.item is not declared as volatile |
244 * even though it is read by releasing threads, because they only |
244 * even though it is read by releasing threads, because they only |
245 * do so after CAS operations that must precede access, and all |
245 * do so after CAS operations that must precede access, and all |
246 * uses by the owning thread are otherwise acceptably ordered by |
246 * uses by the owning thread are otherwise acceptably ordered by |
247 * other operations. (Because the actual points of atomicity are |
247 * other operations. (Because the actual points of atomicity are |
374 long end = (timed && m == 0) ? System.nanoTime() + ns : 0L; |
374 long end = (timed && m == 0) ? System.nanoTime() + ns : 0L; |
375 Thread t = Thread.currentThread(); // wait |
375 Thread t = Thread.currentThread(); // wait |
376 for (int h = p.hash, spins = SPINS;;) { |
376 for (int h = p.hash, spins = SPINS;;) { |
377 Object v = p.match; |
377 Object v = p.match; |
378 if (v != null) { |
378 if (v != null) { |
379 U.putOrderedObject(p, MATCH, null); |
379 U.putObjectRelease(p, MATCH, null); |
380 p.item = null; // clear for next use |
380 p.item = null; // clear for next use |
381 p.hash = h; |
381 p.hash = h; |
382 return v; |
382 return v; |
383 } |
383 } |
384 else if (spins > 0) { |
384 else if (spins > 0) { |
505 else if (U.compareAndSwapObject(this, SLOT, p, null)) { |
505 else if (U.compareAndSwapObject(this, SLOT, p, null)) { |
506 v = timed && ns <= 0L && !t.isInterrupted() ? TIMED_OUT : null; |
506 v = timed && ns <= 0L && !t.isInterrupted() ? TIMED_OUT : null; |
507 break; |
507 break; |
508 } |
508 } |
509 } |
509 } |
510 U.putOrderedObject(p, MATCH, null); |
510 U.putObjectRelease(p, MATCH, null); |
511 p.item = null; |
511 p.item = null; |
512 p.hash = h; |
512 p.hash = h; |
513 return v; |
513 return v; |
514 } |
514 } |
515 |
515 |