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

Comparing jsr166/src/main/java/util/concurrent/ConcurrentSkipListMap.java (file contents):
Revision 1.140 by jsr166, Sun Jan 4 01:06:15 2015 UTC vs.
Revision 1.141 by jsr166, Sun Jan 4 09:15:11 2015 UTC

# Line 371 | Line 371 | public class ConcurrentSkipListMap<K,V>
371       * compareAndSet head node
372       */
373      private boolean casHead(HeadIndex<K,V> cmp, HeadIndex<K,V> val) {
374 <        return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val);
374 >        return U.compareAndSwapObject(this, HEAD, cmp, val);
375      }
376  
377      /* ---------------- Nodes -------------- */
# Line 414 | Line 414 | public class ConcurrentSkipListMap<K,V>
414           * compareAndSet value field
415           */
416          boolean casValue(Object cmp, Object val) {
417 <            return UNSAFE.compareAndSwapObject(this, valueOffset, cmp, val);
417 >            return U.compareAndSwapObject(this, VALUE, cmp, val);
418          }
419  
420          /**
421           * compareAndSet next field
422           */
423          boolean casNext(Node<K,V> cmp, Node<K,V> val) {
424 <            return UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val);
424 >            return U.compareAndSwapObject(this, NEXT, cmp, val);
425          }
426  
427          /**
# Line 502 | Line 502 | public class ConcurrentSkipListMap<K,V>
502              return new AbstractMap.SimpleImmutableEntry<K,V>(key, vv);
503          }
504  
505 <        // UNSAFE mechanics
505 >        // Unsafe mechanics
506  
507 <        private static final sun.misc.Unsafe UNSAFE;
508 <        private static final long valueOffset;
509 <        private static final long nextOffset;
507 >        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
508 >        private static final long VALUE;
509 >        private static final long NEXT;
510  
511          static {
512              try {
513 <                UNSAFE = sun.misc.Unsafe.getUnsafe();
514 <                Class<?> k = Node.class;
515 <                valueOffset = UNSAFE.objectFieldOffset
516 <                    (k.getDeclaredField("value"));
517 <                nextOffset = UNSAFE.objectFieldOffset
518 <                    (k.getDeclaredField("next"));
513 >                VALUE = U.objectFieldOffset
514 >                    (Node.class.getDeclaredField("value"));
515 >                NEXT = U.objectFieldOffset
516 >                    (Node.class.getDeclaredField("next"));
517              } catch (ReflectiveOperationException e) {
518                  throw new Error(e);
519              }
# Line 549 | Line 547 | public class ConcurrentSkipListMap<K,V>
547           * compareAndSet right field
548           */
549          final boolean casRight(Index<K,V> cmp, Index<K,V> val) {
550 <            return UNSAFE.compareAndSwapObject(this, rightOffset, cmp, val);
550 >            return U.compareAndSwapObject(this, RIGHT, cmp, val);
551          }
552  
553          /**
# Line 586 | Line 584 | public class ConcurrentSkipListMap<K,V>
584          }
585  
586          // Unsafe mechanics
587 <        private static final sun.misc.Unsafe UNSAFE;
588 <        private static final long rightOffset;
587 >        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
588 >        private static final long RIGHT;
589          static {
590              try {
591 <                UNSAFE = sun.misc.Unsafe.getUnsafe();
592 <                Class<?> k = Index.class;
595 <                rightOffset = UNSAFE.objectFieldOffset
596 <                    (k.getDeclaredField("right"));
591 >                RIGHT = U.objectFieldOffset
592 >                    (Index.class.getDeclaredField("right"));
593              } catch (ReflectiveOperationException e) {
594                  throw new Error(e);
595              }
# Line 3547 | Line 3543 | public class ConcurrentSkipListMap<K,V>
3543      }
3544  
3545      // Unsafe mechanics
3546 <    private static final sun.misc.Unsafe UNSAFE;
3547 <    private static final long headOffset;
3546 >    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
3547 >    private static final long HEAD;
3548      private static final long SECONDARY;
3549      static {
3550          try {
3551 <            UNSAFE = sun.misc.Unsafe.getUnsafe();
3552 <            Class<?> k = ConcurrentSkipListMap.class;
3553 <            headOffset = UNSAFE.objectFieldOffset
3554 <                (k.getDeclaredField("head"));
3555 <            Class<?> tk = Thread.class;
3560 <            SECONDARY = UNSAFE.objectFieldOffset
3561 <                (tk.getDeclaredField("threadLocalRandomSecondarySeed"));
3551 >            HEAD = U.objectFieldOffset
3552 >                (ConcurrentSkipListMap.class.getDeclaredField("head"));
3553 >
3554 >            SECONDARY = U.objectFieldOffset
3555 >                (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed"));
3556          } catch (ReflectiveOperationException e) {
3557              throw new Error(e);
3558          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines