< prev index next >

src/java.base/share/classes/sun/nio/ch/SelectionKeyImpl.java

Print this page
rev 50426 : [mq]: 6350055

*** 23,32 **** --- 23,35 ---- * questions. */ package sun.nio.ch; + import java.lang.invoke.ConstantBootstraps; + import java.lang.invoke.MethodHandles; + import java.lang.invoke.VarHandle; import java.nio.channels.CancelledKeyException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.spi.AbstractSelectionKey;
*** 37,46 **** --- 40,56 ---- */ public final class SelectionKeyImpl extends AbstractSelectionKey { + private static final VarHandle INTERESTOPS = + ConstantBootstraps.fieldVarHandle( + MethodHandles.lookup(), + "interestOps", + VarHandle.class, + SelectionKeyImpl.class, int.class); + private final SelChImpl channel; private final SelectorImpl selector; private volatile int interestOps; private volatile int readyOps;
*** 82,92 **** } @Override public SelectionKey interestOps(int ops) { ensureValid(); ! return nioInterestOps(ops); } @Override public int readyOps() { ensureValid(); --- 92,130 ---- } @Override public SelectionKey interestOps(int ops) { ensureValid(); ! if ((ops & ~channel().validOps()) != 0) ! throw new IllegalArgumentException(); ! int oldOps = (int) INTERESTOPS.getAndSet(this, ops); ! if (ops != oldOps) { ! selector.setEventOps(this); ! } ! return this; ! } ! ! @Override ! public int interestOpsOr(int ops) { ! ensureValid(); ! if ((ops & ~channel().validOps()) != 0) ! throw new IllegalArgumentException(); ! int oldVal = (int) INTERESTOPS.getAndBitwiseOr(this, ops); ! if (oldVal != (oldVal | ops)) { ! selector.setEventOps(this); ! } ! return oldVal; ! } ! ! @Override ! public int interestOpsAnd(int ops) { ! ensureValid(); ! int oldVal = (int) INTERESTOPS.getAndBitwiseAnd(this, ops); ! if (oldVal != (oldVal & ops)) { ! selector.setEventOps(this); ! } ! return oldVal; } @Override public int readyOps() { ensureValid();
< prev index next >