src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java
author alanb
Thu, 25 Apr 2019 10:41:49 +0100
changeset 54620 13b67c1420b8
parent 52427 3c6aa484536c
child 54754 193a8f1a4f3b
permissions -rw-r--r--
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks Reviewed-by: dfuchs, bpb, martin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
54620
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
     2
 * Copyright (c) 2000, 2019, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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;
54620
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
    29
import java.nio.channels.AsynchronousCloseException;
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
    30
import java.nio.channels.Channel;
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
    31
import java.nio.channels.ClosedByInterruptException;
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
    32
import java.nio.channels.InterruptibleChannel;
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
    33
import java.util.concurrent.locks.ReentrantLock;
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
    34
52427
3c6aa484536c 8211122: Reduce the number of internal classes made accessible to jdk.unsupported
mchung
parents: 49001
diff changeset
    35
import jdk.internal.access.SharedSecrets;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.nio.ch.Interruptible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Base implementation class for interruptible channels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p> This class encapsulates the low-level machinery required to implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the asynchronous closing and interruption of channels.  A concrete channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * class must invoke the {@link #begin begin} and {@link #end end} methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * before and after, respectively, invoking an I/O operation that might block
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * indefinitely.  In order to ensure that the {@link #end end} method is always
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * invoked, these methods should be used within a
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 27757
diff changeset
    48
 * {@code try}&nbsp;...&nbsp;{@code finally} block:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
47004
b7e72fc752c9 8186684: Fix broken links in java.base API docs
jjg
parents: 34774
diff changeset
    50
 * <blockquote><pre id="be">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * boolean completed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *     begin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *     completed = ...;    // Perform blocking I/O operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *     return ...;         // Return result
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *     end(completed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * }</pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 27757
diff changeset
    60
 * <p> The {@code completed} argument to the {@link #end end} method tells
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * whether or not the I/O operation actually completed, that is, whether it had
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * any effect that would be visible to the invoker.  In the case of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * operation that reads bytes, for example, this argument should be
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 27757
diff changeset
    64
 * {@code true} if, and only if, some bytes were actually transferred into the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * invoker's target buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <p> A concrete channel class must also implement the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * #implCloseChannel implCloseChannel} method in such a way that if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * invoked while another thread is blocked in a native I/O operation upon the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * channel then that operation will immediately return, either by throwing an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * exception or by returning normally.  If a thread is interrupted or the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * channel upon which it is blocked is asynchronously closed then the channel's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * {@link #end end} method will throw the appropriate exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <p> This class performs the synchronization required to implement the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * java.nio.channels.Channel} specification.  Implementations of the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * #implCloseChannel implCloseChannel} method need not synchronize against
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * other threads that might be attempting to close the channel.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * @author Mark Reinhold
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * @author JSR-51 Expert Group
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
public abstract class AbstractInterruptibleChannel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    implements Channel, InterruptibleChannel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
{
54620
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
    89
    private final ReentrantLock closeLock = new ReentrantLock();
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 32834
diff changeset
    90
    private volatile boolean closed;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Initializes a new instance of this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    protected AbstractInterruptibleChannel() { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Closes this channel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * <p> If the channel has already been closed then this method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * immediately.  Otherwise it marks the channel as closed and then invokes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * the {@link #implCloseChannel implCloseChannel} method in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * complete the close operation.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @throws  IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *          If an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public final void close() throws IOException {
54620
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
   109
        closeLock.lock();
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
   110
        try {
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 32834
diff changeset
   111
            if (closed)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                return;
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 32834
diff changeset
   113
            closed = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            implCloseChannel();
54620
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
   115
        } finally {
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
   116
            closeLock.unlock();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Closes this channel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * <p> This method is invoked by the {@link #close close} method in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * to perform the actual work of closing the channel.  This method is only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * invoked if the channel has not yet been closed, and it is never invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * more than once.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <p> An implementation of this method must arrange for any other thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * that is blocked in an I/O operation upon this channel to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * immediately, either by throwing an exception or by returning normally.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @throws  IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *          If an I/O error occurs while closing the channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    protected abstract void implCloseChannel() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public final boolean isOpen() {
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 32834
diff changeset
   139
        return !closed;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    // -- Interruption machinery --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    private Interruptible interruptor;
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   146
    private volatile Thread interrupted;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Marks the beginning of an I/O operation that might block indefinitely.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * <p> This method should be invoked in tandem with the {@link #end end}
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 27757
diff changeset
   152
     * method, using a {@code try}&nbsp;...&nbsp;{@code finally} block as
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * shown <a href="#be">above</a>, in order to implement asynchronous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * closing and interruption for this channel.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    protected final void begin() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (interruptor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            interruptor = new Interruptible() {
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   159
                    public void interrupt(Thread target) {
54620
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
   160
                        closeLock.lock();
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
   161
                        try {
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 32834
diff changeset
   162
                            if (closed)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                                return;
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 32834
diff changeset
   164
                            closed = true;
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   165
                            interrupted = target;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                                AbstractInterruptibleChannel.this.implCloseChannel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                            } catch (IOException x) { }
54620
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
   169
                        } finally {
13b67c1420b8 8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents: 52427
diff changeset
   170
                            closeLock.unlock();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                    }};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        blockedOn(interruptor);
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   175
        Thread me = Thread.currentThread();
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   176
        if (me.isInterrupted())
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   177
            interruptor.interrupt(me);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Marks the end of an I/O operation that might block indefinitely.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <p> This method should be invoked in tandem with the {@link #begin
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 27757
diff changeset
   184
     * begin} method, using a {@code try}&nbsp;...&nbsp;{@code finally} block
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * as shown <a href="#be">above</a>, in order to implement asynchronous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * closing and interruption for this channel.  </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param  completed
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 27757
diff changeset
   189
     *         {@code true} if, and only if, the I/O operation completed
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *         successfully, that is, had some effect that would be visible to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *         the operation's invoker
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @throws  AsynchronousCloseException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *          If the channel was asynchronously closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @throws  ClosedByInterruptException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *          If the thread blocked in the I/O operation was interrupted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    protected final void end(boolean completed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        throws AsynchronousCloseException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        blockedOn(null);
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   203
        Thread interrupted = this.interrupted;
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   204
        if (interrupted != null && interrupted == Thread.currentThread()) {
27757
0317e4973b42 8065720: (ch) AbstractInterruptibleChannel.end sets interrupted to null
alanb
parents: 25859
diff changeset
   205
            this.interrupted = null;
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   206
            throw new ClosedByInterruptException();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 32834
diff changeset
   208
        if (!completed && closed)
7177
0113db4feebc 6979009: (fc) FileChannel.read() fails to throw ClosedByInterruptException
alanb
parents: 5506
diff changeset
   209
            throw new AsynchronousCloseException();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
52427
3c6aa484536c 8211122: Reduce the number of internal classes made accessible to jdk.unsupported
mchung
parents: 49001
diff changeset
   213
    // -- jdk.internal.access.SharedSecrets --
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    static void blockedOn(Interruptible intr) {         // package-private
49001
ce06058197a4 8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents: 47216
diff changeset
   215
        SharedSecrets.getJavaLangAccess().blockedOn(intr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
}