src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke


1579                     stat = false;
1580             }
1581             return stat;
1582         }
1583 
1584         /**
1585          * Processes exception in Subscriber.onNext.
1586          */
1587         private void handleOnNext(Flow.Subscriber<? super T> s, Throwable ex) {
1588             BiConsumer<? super Flow.Subscriber<? super T>, ? super Throwable> h;
1589             if ((h = onNextHandler) != null) {
1590                 try {
1591                     h.accept(s, ex);
1592                 } catch (Throwable ignore) {
1593                 }
1594             }
1595             onError(ex);
1596         }
1597 
1598         // Unsafe mechanics
1599         private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
1600         private static final long CTL;
1601         private static final long TAIL;
1602         private static final long HEAD;
1603         private static final long DEMAND;
1604         private static final int ABASE;
1605         private static final int ASHIFT;
1606 
1607         static {
1608             try {
1609                 CTL = U.objectFieldOffset
1610                     (BufferedSubscription.class.getDeclaredField("ctl"));
1611                 TAIL = U.objectFieldOffset
1612                     (BufferedSubscription.class.getDeclaredField("tail"));
1613                 HEAD = U.objectFieldOffset
1614                     (BufferedSubscription.class.getDeclaredField("head"));
1615                 DEMAND = U.objectFieldOffset
1616                     (BufferedSubscription.class.getDeclaredField("demand"));
1617 
1618                 ABASE = U.arrayBaseOffset(Object[].class);
1619                 int scale = U.arrayIndexScale(Object[].class);


1579                     stat = false;
1580             }
1581             return stat;
1582         }
1583 
1584         /**
1585          * Processes exception in Subscriber.onNext.
1586          */
1587         private void handleOnNext(Flow.Subscriber<? super T> s, Throwable ex) {
1588             BiConsumer<? super Flow.Subscriber<? super T>, ? super Throwable> h;
1589             if ((h = onNextHandler) != null) {
1590                 try {
1591                     h.accept(s, ex);
1592                 } catch (Throwable ignore) {
1593                 }
1594             }
1595             onError(ex);
1596         }
1597 
1598         // Unsafe mechanics
1599         private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
1600         private static final long CTL;
1601         private static final long TAIL;
1602         private static final long HEAD;
1603         private static final long DEMAND;
1604         private static final int ABASE;
1605         private static final int ASHIFT;
1606 
1607         static {
1608             try {
1609                 CTL = U.objectFieldOffset
1610                     (BufferedSubscription.class.getDeclaredField("ctl"));
1611                 TAIL = U.objectFieldOffset
1612                     (BufferedSubscription.class.getDeclaredField("tail"));
1613                 HEAD = U.objectFieldOffset
1614                     (BufferedSubscription.class.getDeclaredField("head"));
1615                 DEMAND = U.objectFieldOffset
1616                     (BufferedSubscription.class.getDeclaredField("demand"));
1617 
1618                 ABASE = U.arrayBaseOffset(Object[].class);
1619                 int scale = U.arrayIndexScale(Object[].class);