mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
8198754: (ch) Separate blocking and non-blocking code paths (part 2) Reviewed-by: bpb
This commit is contained in:
parent
3918ed17a5
commit
13dd8888d2
16 changed files with 1645 additions and 1279 deletions
|
@ -2080,8 +2080,8 @@ public final class System {
|
|||
E[] getEnumConstantsShared(Class<E> klass) {
|
||||
return klass.getEnumConstantsShared();
|
||||
}
|
||||
public void blockedOn(Thread t, Interruptible b) {
|
||||
t.blockedOn(b);
|
||||
public void blockedOn(Interruptible b) {
|
||||
Thread.blockedOn(b);
|
||||
}
|
||||
public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
|
||||
Shutdown.add(slot, registerShutdownInProgress, hook);
|
||||
|
|
|
@ -231,9 +231,10 @@ class Thread implements Runnable {
|
|||
/* Set the blocker field; invoked via jdk.internal.misc.SharedSecrets
|
||||
* from java.nio code
|
||||
*/
|
||||
void blockedOn(Interruptible b) {
|
||||
synchronized (blockerLock) {
|
||||
blocker = b;
|
||||
static void blockedOn(Interruptible b) {
|
||||
Thread me = Thread.currentThread();
|
||||
synchronized (me.blockerLock) {
|
||||
me.blocker = b;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1006,18 +1007,22 @@ class Thread implements Runnable {
|
|||
* @spec JSR-51
|
||||
*/
|
||||
public void interrupt() {
|
||||
if (this != Thread.currentThread())
|
||||
Thread me = Thread.currentThread();
|
||||
if (this != me)
|
||||
checkAccess();
|
||||
|
||||
synchronized (blockerLock) {
|
||||
Interruptible b = blocker;
|
||||
if (b != null) {
|
||||
interrupt0(); // Just to set the interrupt flag
|
||||
b.interrupt(this);
|
||||
return;
|
||||
// set interrupt status
|
||||
interrupt0();
|
||||
|
||||
// thread may be blocked in an I/O operation
|
||||
if (this != me && blocker != null) {
|
||||
synchronized (blockerLock) {
|
||||
Interruptible b = blocker;
|
||||
if (b != null) {
|
||||
b.interrupt(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
interrupt0();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -205,6 +205,6 @@ public abstract class AbstractInterruptibleChannel
|
|||
|
||||
// -- jdk.internal.misc.SharedSecrets --
|
||||
static void blockedOn(Interruptible intr) { // package-private
|
||||
SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), intr);
|
||||
SharedSecrets.getJavaLangAccess().blockedOn(intr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue