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.56 by jsr166, Fri Dec 23 20:43:21 2011 UTC vs.
Revision 1.57 by jsr166, Fri Dec 23 20:48:39 2011 UTC

# Line 76 | Line 76 | import java.util.concurrent.locks.LockSu
76   public class Exchanger<V> {
77  
78      /*
79 <     * Oveview: The core algorithm is, for an exchange "slot",
79 >     * Overview: The core algorithm is, for an exchange "slot",
80       * and a participant (caller) with an item:
81       *
82       *   for (;;) {
# Line 114 | Line 114 | public class Exchanger<V> {
114       * and related bookkeeping state. (We can safely reuse per-thread
115       * nodes rather than creating them fresh each time because slots
116       * alternate between pointing to a node vs null, so cannot
117 <     * encounter ABA problems. However, we do need som care in
117 >     * encounter ABA problems. However, we do need some care in
118       * resetting them between uses.)
119       *
120       * Implementing an effective arena requires allocating a bunch of
# Line 203 | Line 203 | public class Exchanger<V> {
203       * both methods may be called. This is done by using null return
204       * as a sentinel to recheck interrupt status.)
205       *
206 <     * As is too common in this sort of code, methods are monolothic
206 >     * As is too common in this sort of code, methods are monolithic
207       * because most of the logic relies on reads of fields that are
208       * maintained as local variables so can't be nicely factored --
209       * mainly, here, bulky spin->yield->block/cancel code), and
210       * heavily dependent on intrinsics (Unsafe) to use inlined
211 <     * embedded CAS and related mameory access operations (that tend
211 >     * embedded CAS and related memory access operations (that tend
212       * not to be as readily inlined by dynamic compilers when they are
213       * hidden behind other methods that would more nicely name and
214       * encapsulate the intended effects). This includes the use of
215       * putOrderedX to clear fields of the per-thread Nodes between
216       * uses. Note that field Node.item is not declared as volatile
217       * even though it is read by releasing threads, because they only
218 <     * do so after CAS operations that must preceed access, and all
218 >     * do so after CAS operations that must precede access, and all
219       * uses by the owning thread are otherwise acceptably ordered by
220       * other operations. (Because the actual points of atomicity are
221       * slot CASes, it would also be legal for the write to Node.match

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines