jdk/src/java.base/share/classes/java/nio/channels/spi/AbstractSelector.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 23010 jdk/src/share/classes/java/nio/channels/spi/AbstractSelector.java@6dadb192ad81
child 32143 394ab6a6658d
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 18574
diff changeset
     2
 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.nio.channels.spi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.nio.channels.SelectionKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.nio.channels.Selector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.nio.ch.Interruptible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.concurrent.atomic.AtomicBoolean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Base implementation class for selectors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p> This class encapsulates the low-level machinery required to implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * the interruption of selection operations.  A concrete selector class must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * invoke the {@link #begin begin} and {@link #end end} methods before and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * after, respectively, invoking an I/O operation that might block
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * indefinitely.  In order to ensure that the {@link #end end} method is always
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * invoked, these methods should be used within a
18574
4aeaeb541678 8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents: 18164
diff changeset
    46
 * <tt>try</tt>&nbsp;...&nbsp;<tt>finally</tt> block:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *     begin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *     // Perform blocking I/O operation here
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *     ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *     end();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * }</pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <p> This class also defines methods for maintaining a selector's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * cancelled-key set and for removing a key from its channel's key set, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * declares the abstract {@link #register register} method that is invoked by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * selectable channel's {@link AbstractSelectableChannel#register register}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * method in order to perform the actual work of registering a channel.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * @author Mark Reinhold
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @author JSR-51 Expert Group
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
public abstract class AbstractSelector
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    extends Selector
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private AtomicBoolean selectorOpen = new AtomicBoolean(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    // The provider that created this selector
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private final SelectorProvider provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
18164
68f1bc4eadd4 8016370: javadoc warnings, unexpected </p> mostly
alanb
parents: 7668
diff changeset
    79
     * Initializes a new instance of this class.
18574
4aeaeb541678 8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents: 18164
diff changeset
    80
     *
4aeaeb541678 8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents: 18164
diff changeset
    81
     * @param  provider
4aeaeb541678 8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents: 18164
diff changeset
    82
     *         The provider that created this selector
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    protected AbstractSelector(SelectorProvider provider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        this.provider = provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
895
67f1dc69ad10 6726309: Compiler warnings in nio code
alanb
parents: 2
diff changeset
    88
    private final Set<SelectionKey> cancelledKeys = new HashSet<SelectionKey>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    void cancel(SelectionKey k) {                       // package-private
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        synchronized (cancelledKeys) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            cancelledKeys.add(k);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Closes this selector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * <p> If the selector has already been closed then this method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * immediately.  Otherwise it marks the selector as closed and then invokes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * the {@link #implCloseSelector implCloseSelector} method in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * complete the close operation.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @throws  IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *          If an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public final void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        boolean open = selectorOpen.getAndSet(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if (!open)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        implCloseSelector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Closes this selector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * <p> This method is invoked by the {@link #close close} method in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * to perform the actual work of closing the selector.  This method is only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * invoked if the selector has not yet been closed, and it is never invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * more than once.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * <p> An implementation of this method must arrange for any other thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * that is blocked in a selection operation upon this selector to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * immediately as if by invoking the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * java.nio.channels.Selector#wakeup wakeup} method. </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @throws  IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *          If an I/O error occurs while closing the selector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    protected abstract void implCloseSelector() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public final boolean isOpen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return selectorOpen.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Returns the provider that created this channel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @return  The provider that created this channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public final SelectorProvider provider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        return provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Retrieves this selector's cancelled-key set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <p> This set should only be used while synchronized upon it.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @return  The cancelled-key set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    protected final Set<SelectionKey> cancelledKeys() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        return cancelledKeys;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Registers the given channel with this selector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * <p> This method is invoked by a channel's {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * AbstractSelectableChannel#register register} method in order to perform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * the actual work of registering the channel with this selector.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param  ch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *         The channel to be registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param  ops
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *         The initial interest set, which must be valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param  att
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *         The initial attachment for the resulting key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @return  A new key representing the registration of the given channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *          with this selector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    protected abstract SelectionKey register(AbstractSelectableChannel ch,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                                             int ops, Object att);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * Removes the given key from its channel's key set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * <p> This method must be invoked by the selector for each channel that it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * deregisters.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @param  key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *         The selection key to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    protected final void deregister(AbstractSelectionKey key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        ((AbstractSelectableChannel)key.channel()).removeKey(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    // -- Interruption machinery --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    private Interruptible interruptor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * Marks the beginning of an I/O operation that might block indefinitely.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * <p> This method should be invoked in tandem with the {@link #end end}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * method, using a <tt>try</tt>&nbsp;...&nbsp;<tt>finally</tt> block as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * shown <a href="#be">above</a>, in order to implement interruption for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * this selector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <p> Invoking this method arranges for the selector's {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Selector#wakeup wakeup} method to be invoked if a thread's {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * Thread#interrupt interrupt} method is invoked while the thread is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * blocked in an I/O operation upon the selector.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    protected final void begin() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        if (interruptor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            interruptor = new Interruptible() {
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   212
                    public void interrupt(Thread ignore) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                        AbstractSelector.this.wakeup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    }};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        AbstractInterruptibleChannel.blockedOn(interruptor);
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   217
        Thread me = Thread.currentThread();
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   218
        if (me.isInterrupted())
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   219
            interruptor.interrupt(me);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Marks the end of an I/O operation that might block indefinitely.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <p> This method should be invoked in tandem with the {@link #begin begin}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * method, using a <tt>try</tt>&nbsp;...&nbsp;<tt>finally</tt> block as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * shown <a href="#be">above</a>, in order to implement interruption for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * this selector.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    protected final void end() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        AbstractInterruptibleChannel.blockedOn(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
}