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.60 by jsr166, Mon Jan 2 23:46:33 2012 UTC vs.
Revision 1.61 by jsr166, Sun Nov 25 21:34:39 2012 UTC

# Line 79 | Line 79 | public class Exchanger<V> {
79       * Overview: The core algorithm is, for an exchange "slot",
80       * and a participant (caller) with an item:
81       *
82 <     *   for (;;) {
83 <     *       if (slot is empty) {                       // offer
84 <     *           place item in a Node;
85 <     *           if (can CAS slot from empty to node) {
86 <     *                wait for release;
87 <     *                return matching item in node;
88 <     *           }
89 <     *      }
90 <     *      else if (can CAS slot from node to empty) { // release
91 <     *          get the item in node;
92 <     *          set matching item in node;
93 <     *          release waiting thread;
82 >     * for (;;) {
83 >     *   if (slot is empty) {                       // offer
84 >     *     place item in a Node;
85 >     *     if (can CAS slot from empty to node) {
86 >     *        wait for release;
87 >     *        return matching item in node;
88       *     }
89 <     *     // else retry on CAS failure
90 <     *  }
89 >     *   }
90 >     *   else if (can CAS slot from node to empty) { // release
91 >     *     get the item in node;
92 >     *     set matching item in node;
93 >     *     release waiting thread;
94 >     *   }
95 >     *   // else retry on CAS failure
96 >     * }
97       *
98       * This is among the simplest forms of a "dual data structure" --
99       * see Scott and Scherer's DISC 04 paper and

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines