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.30 by dl, Sun Nov 6 15:30:24 2005 UTC vs.
Revision 1.31 by jsr166, Sun Nov 6 21:34:52 2005 UTC

# Line 138 | Line 138 | public class Exchanger<V> {
138      /**
139       * The collision arena. arena[0] is used as the top of the stack.
140       * The remainder is used as the collision elimination space.
141     * Each slot holds an AtomicReference<Node>, but this cannot be
142     * expressed for arrays, so elements are casted on each use.
141       */
142      private final AtomicReference<Node>[] arena;
143  
# Line 217 | Line 215 | public class Exchanger<V> {
215      }
216  
217      /**
218 <     * Returns a random delay less than (base times (2 raised to backoff))
218 >     * Returns a random delay less than (base times (2 raised to backoff)).
219       */
220      private long randomDelay(int backoff) {
221          return ((BACKOFF_BASE << backoff) - 1) & random.nextInt();
# Line 235 | Line 233 | public class Exchanger<V> {
233  
234          /** The element offered by the Thread creating this node. */
235          final Object item;
236 +
237          /** The Thread creating this node. */
238          final Thread waiter;
239  
240          /**
241           * Creates node with given item and empty hole.
242 <         * @param item the item.
242 >         *
243 >         * @param item the item
244           */
245          Node(Object item) {
246              this.item = item;
# Line 249 | Line 249 | public class Exchanger<V> {
249  
250          /**
251           * Tries to fill in hole. On success, wakes up the waiter.
252 <         * @param val the value to place in hole.
253 <         * @return on success, the item; on failure, FAIL.
252 >         *
253 >         * @param val the value to place in hole
254 >         * @return on success, the item; on failure, FAIL
255           */
256          Object fillHole(Object val) {
257              if (compareAndSet(null, val)) {
# Line 294 | Line 295 | public class Exchanger<V> {
295  
296      /**
297       * Waits for another thread to arrive at this exchange point (unless
298 <     * it is {@link Thread#interrupt interrupted}),
298 >     * the current thread is {@link Thread#interrupt interrupted}),
299       * and then transfers the given object to it, receiving its object
300       * in return.
301       *
# Line 335 | Line 336 | public class Exchanger<V> {
336  
337      /**
338       * Waits for another thread to arrive at this exchange point (unless
339 <     * it is {@link Thread#interrupt interrupted}, or the specified waiting
340 <     * time elapses),
341 <     * and then transfers the given object to it, receiving its object
341 <     * in return.
339 >     * the current thread is {@link Thread#interrupt interrupted} or
340 >     * the specified waiting time elapses), and then transfers the given
341 >     * object to it, receiving its object in return.
342       *
343       * <p>If another thread is already waiting at the exchange point then
344       * it is resumed for thread scheduling purposes and receives the object

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines