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

Comparing jsr166/src/main/java/util/concurrent/Exchanger.java (file contents):
Revision 1.39 by jsr166, Mon Feb 13 05:29:31 2006 UTC vs.
Revision 1.40 by jsr166, Mon Feb 13 08:12:10 2006 UTC

# Line 300 | Line 300 | public class Exchanger<V> {
300       * handling of sentinel values.  Callers from public methods decode
301       * and cast accordingly.
302       *
303 <     * @param item the (nonnull) item to exchange
303 >     * @param item the (non-null) item to exchange
304       * @param timed true if the wait is timed
305       * @param nanos if timed, the maximum wait time
306       * @return the other thread's item, or CANCEL if interrupted or timed out
# Line 318 | Line 318 | public class Exchanger<V> {
318              else if ((y = slot.get()) != null &&  // Try to fulfill
319                       slot.compareAndSet(y, null)) {
320                  Node you = (Node)y;               // Transfer item
321 <                if (you.compareAndSet(null, me.item)) {
321 >                if (you.compareAndSet(null, item)) {
322                      LockSupport.unpark(you.waiter);
323                      return you.item;
324                  }                                 // Else cancelled; continue
# Line 330 | Line 330 | public class Exchanger<V> {
330                  Object v = spinWait(me, slot);    // Spin wait for non-0
331                  if (v != CANCEL)
332                      return v;
333 <                me = new Node(me.item);           // Throw away cancelled node
333 >                me = new Node(item);              // Throw away cancelled node
334                  int m = max.get();
335                  if (m > (index >>>= 1))           // Decrease index
336                      max.compareAndSet(m, m - 1);  // Maybe shrink table
# Line 391 | Line 391 | public class Exchanger<V> {
391          // Create slot outside of lock to narrow sync region
392          Slot newSlot = new Slot();
393          Slot[] a = arena;
394 <        synchronized(a) {
394 >        synchronized (a) {
395              if (a[index] == null)
396                  a[index] = newSlot;
397          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines