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.40 by jsr166, Mon Feb 13 08:12:10 2006 UTC vs.
Revision 1.41 by dl, Mon Feb 13 12:38:45 2006 UTC

# Line 288 | Line 288 | public class Exchanger<V> {
288      /**
289       * The maximum slot index being used.  The value sometimes
290       * increases when a thread experiences too many CAS contentions,
291 <     * and sometimes decreases when a backoff wait elapses.  Changes
291 >     * and sometimes decreases when a spin-wait elapses.  Changes
292       * are performed only via compareAndSet, to avoid stale values
293       * when a thread happens to stall right before setting.
294       */
# Line 382 | Line 382 | public class Exchanger<V> {
382  
383      /**
384       * Creates a new slot at given index.  Called only when the slot
385 <     * appears to be null.  Relies on double-check using builtin locks,
386 <     * since they rarely contend.
385 >     * appears to be null.  Relies on double-check using builtin
386 >     * locks, since they rarely contend. This in turn relies on the
387 >     * arena array being declared volatile.
388       *
389       * @param index the index to add slot at
390       */
# Line 398 | Line 399 | public class Exchanger<V> {
399      }
400  
401      /**
402 <     * Try to cancel a wait for the given node waiting in the given
402 >     * Trie to cancel a wait for the given node waiting in the given
403       * slot, if so, helping clear the node from its slot to avoid
404       * garbage retention.
405       *
# Line 409 | Line 410 | public class Exchanger<V> {
410      private static boolean tryCancel(Node node, Slot slot) {
411          if (!node.compareAndSet(null, CANCEL))
412              return false;
413 <        if (slot.get() == node)
413 >        if (slot.get() == node) // pre-check to minimize contention
414              slot.compareAndSet(node, null);
415          return true;
416      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines