src/java.base/share/classes/java/nio/channels/SelectionKey.java
changeset 49802 8ac08fa69f00
parent 47216 71c04702a3d5
child 50439 c5c827f3bf72
equal deleted inserted replaced
49801:466d4df248a6 49802:8ac08fa69f00
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2018, 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
    84  * implement that protocol.  Selection keys therefore support the
    84  * implement that protocol.  Selection keys therefore support the
    85  * <i>attachment</i> of a single arbitrary object to a key.  An object can be
    85  * <i>attachment</i> of a single arbitrary object to a key.  An object can be
    86  * attached via the {@link #attach attach} method and then later retrieved via
    86  * attached via the {@link #attach attach} method and then later retrieved via
    87  * the {@link #attachment() attachment} method.
    87  * the {@link #attachment() attachment} method.
    88  *
    88  *
    89  * <p> Selection keys are safe for use by multiple concurrent threads.  The
    89  * <p> Selection keys are safe for use by multiple concurrent threads.  A
    90  * operations of reading and writing the interest set will, in general, be
    90  * selection operation will always use the interest-set value that was current
    91  * synchronized with certain operations of the selector.  Exactly how this
    91  * at the moment that the operation began.  </p>
    92  * synchronization is performed is implementation-dependent: In a naive
       
    93  * implementation, reading or writing the interest set may block indefinitely
       
    94  * if a selection operation is already in progress; in a high-performance
       
    95  * implementation, reading or writing the interest set may block briefly, if at
       
    96  * all.  In any case, a selection operation will always use the interest-set
       
    97  * value that was current at the moment that the operation began.  </p>
       
    98  *
    92  *
    99  *
    93  *
   100  * @author Mark Reinhold
    94  * @author Mark Reinhold
   101  * @author JSR-51 Expert Group
    95  * @author JSR-51 Expert Group
   102  * @since 1.4
    96  * @since 1.4
   162 
   156 
   163     /**
   157     /**
   164      * Retrieves this key's interest set.
   158      * Retrieves this key's interest set.
   165      *
   159      *
   166      * <p> It is guaranteed that the returned set will only contain operation
   160      * <p> It is guaranteed that the returned set will only contain operation
   167      * bits that are valid for this key's channel.
   161      * bits that are valid for this key's channel. </p>
   168      *
       
   169      * <p> This method may be invoked at any time.  Whether or not it blocks,
       
   170      * and for how long, is implementation-dependent.  </p>
       
   171      *
   162      *
   172      * @return  This key's interest set
   163      * @return  This key's interest set
   173      *
   164      *
   174      * @throws  CancelledKeyException
   165      * @throws  CancelledKeyException
   175      *          If this key has been cancelled
   166      *          If this key has been cancelled
   177     public abstract int interestOps();
   168     public abstract int interestOps();
   178 
   169 
   179     /**
   170     /**
   180      * Sets this key's interest set to the given value.
   171      * Sets this key's interest set to the given value.
   181      *
   172      *
   182      * <p> This method may be invoked at any time.  Whether or not it blocks,
   173      * <p> This method may be invoked at any time.  If this method is invoked
   183      * and for how long, is implementation-dependent.  </p>
   174      * while a selection operation is in progress then it has no effect upon
       
   175      * that operation; the change to the key's interest set will be seen by the
       
   176      * next selection operation.
   184      *
   177      *
   185      * @param  ops  The new interest set
   178      * @param  ops  The new interest set
   186      *
   179      *
   187      * @return  This selection key
   180      * @return  This selection key
   188      *
   181      *