mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8284161: Implementation of Virtual Threads (Preview)
Co-authored-by: Ron Pressler <rpressler@openjdk.org> Co-authored-by: Alan Bateman <alanb@openjdk.org> Co-authored-by: Erik Österlund <eosterlund@openjdk.org> Co-authored-by: Andrew Haley <aph@openjdk.org> Co-authored-by: Rickard Bäckman <rbackman@openjdk.org> Co-authored-by: Markus Grönlund <mgronlun@openjdk.org> Co-authored-by: Leonid Mesnik <lmesnik@openjdk.org> Co-authored-by: Serguei Spitsyn <sspitsyn@openjdk.org> Co-authored-by: Chris Plummer <cjplummer@openjdk.org> Co-authored-by: Coleen Phillimore <coleenp@openjdk.org> Co-authored-by: Robbin Ehn <rehn@openjdk.org> Co-authored-by: Stefan Karlsson <stefank@openjdk.org> Co-authored-by: Thomas Schatzl <tschatzl@openjdk.org> Co-authored-by: Sergey Kuksenko <skuksenko@openjdk.org> Reviewed-by: lancea, eosterlund, rehn, sspitsyn, stefank, tschatzl, dfuchs, lmesnik, dcubed, kevinw, amenkov, dlong, mchung, psandoz, bpb, coleenp, smarks, egahlin, mseledtsov, coffeys, darcy
This commit is contained in:
parent
5212535a27
commit
9583e3657e
1133 changed files with 95935 additions and 8335 deletions
|
@ -55,10 +55,10 @@ import java.util.Arrays;
|
|||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
import jdk.internal.access.JavaNetInetAddressAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
import sun.net.ResolverProviderConfiguration;
|
||||
import sun.security.action.*;
|
||||
|
@ -972,6 +972,7 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
// in cache when the result is obtained
|
||||
private static final class NameServiceAddresses implements Addresses {
|
||||
private final String host;
|
||||
private final ReentrantLock lookupLock = new ReentrantLock();
|
||||
|
||||
NameServiceAddresses(String host) {
|
||||
this.host = host;
|
||||
|
@ -982,7 +983,8 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
Addresses addresses;
|
||||
// only one thread is doing lookup to name service
|
||||
// for particular host at any time.
|
||||
synchronized (this) {
|
||||
lookupLock.lock();
|
||||
try {
|
||||
// re-check that we are still us + re-install us if slot empty
|
||||
addresses = cache.putIfAbsent(host, this);
|
||||
if (addresses == null) {
|
||||
|
@ -1030,6 +1032,8 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
return inetAddresses;
|
||||
}
|
||||
// else addresses != this
|
||||
} finally {
|
||||
lookupLock.unlock();
|
||||
}
|
||||
// delegate to different addresses when we are already replaced
|
||||
// but outside of synchronized block to avoid any chance of dead-locking
|
||||
|
@ -1049,16 +1053,27 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
throws UnknownHostException {
|
||||
Objects.requireNonNull(host);
|
||||
Objects.requireNonNull(policy);
|
||||
return Arrays.stream(impl.lookupAllHostAddr(host, policy));
|
||||
InetAddress[] addrs;
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
addrs = impl.lookupAllHostAddr(host, policy);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
return Arrays.stream(addrs);
|
||||
}
|
||||
|
||||
public String lookupByAddress(byte[] addr)
|
||||
throws UnknownHostException {
|
||||
public String lookupByAddress(byte[] addr) throws UnknownHostException {
|
||||
Objects.requireNonNull(addr);
|
||||
if (addr.length != Inet4Address.INADDRSZ && addr.length != Inet6Address.INADDRSZ) {
|
||||
throw new IllegalArgumentException("Invalid address length");
|
||||
}
|
||||
return impl.getHostByAddr(addr);
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
return impl.getHostByAddr(addr);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue