src/java.base/share/classes/sun/nio/ch/SelectionKeyImpl.java
changeset 59146 455612b3161a
parent 50439 c5c827f3bf72
equal deleted inserted replaced
59145:ea044aedc2b6 59146:455612b3161a
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    56     private volatile int readyOps;
    56     private volatile int readyOps;
    57 
    57 
    58     // registered events in kernel, used by some Selector implementations
    58     // registered events in kernel, used by some Selector implementations
    59     private int registeredEvents;
    59     private int registeredEvents;
    60 
    60 
       
    61     // registered events need to be reset, used by some Selector implementations
       
    62     private volatile boolean reset;
       
    63 
    61     // index of key in pollfd array, used by some Selector implementations
    64     // index of key in pollfd array, used by some Selector implementations
    62     private int index;
    65     private int index;
    63 
    66 
    64     SelectionKeyImpl(SelChImpl ch, SelectorImpl sel) {
    67     SelectionKeyImpl(SelChImpl ch, SelectorImpl sel) {
    65         channel = ch;
    68         channel = ch;
   180         return index;
   183         return index;
   181     }
   184     }
   182 
   185 
   183     void setIndex(int i) {
   186     void setIndex(int i) {
   184         index = i;
   187         index = i;
       
   188     }
       
   189 
       
   190     /**
       
   191      * Sets the reset flag, re-queues the key, and wakeups up the Selector
       
   192      */
       
   193     void reset() {
       
   194         reset = true;
       
   195         selector.setEventOps(this);
       
   196         selector.wakeup();
       
   197     }
       
   198 
       
   199     /**
       
   200      * Clears the reset flag, returning the previous value of the flag
       
   201      */
       
   202     boolean getAndClearReset() {
       
   203         assert Thread.holdsLock(selector);
       
   204         boolean r = reset;
       
   205         if (r)
       
   206             reset = false;
       
   207         return r;
   185     }
   208     }
   186 
   209 
   187     @Override
   210     @Override
   188     public String toString() {
   211     public String toString() {
   189         StringBuilder sb = new StringBuilder();
   212         StringBuilder sb = new StringBuilder();