mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +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
|
@ -25,11 +25,11 @@
|
|||
|
||||
package java.nio;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/* package */ class MappedMemoryUtils {
|
||||
|
||||
|
@ -96,10 +96,15 @@ import java.io.UncheckedIOException;
|
|||
} else {
|
||||
// force writeback via file descriptor
|
||||
long offset = mappingOffset(address, index);
|
||||
long mappingAddress = mappingAddress(address, offset, index);
|
||||
long mappingLength = mappingLength(offset, length);
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
force0(fd, mappingAddress(address, offset, index), mappingLength(offset, length));
|
||||
force0(fd, mappingAddress, mappingLength);
|
||||
} catch (IOException cause) {
|
||||
throw new UncheckedIOException(cause);
|
||||
} finally {
|
||||
Blocker.end(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2022, 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
|
||||
|
@ -76,7 +76,7 @@ public abstract class AbstractSelectableChannel
|
|||
// Lock for registration and configureBlocking operations
|
||||
private final Object regLock = new Object();
|
||||
|
||||
// True when non-blocking, need regLock to change;
|
||||
// True when the channel is configured non-blocking, need regLock to change;
|
||||
private volatile boolean nonBlocking;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2022, 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
|
||||
|
@ -25,6 +25,7 @@
|
|||
|
||||
package java.nio.charset;
|
||||
|
||||
import jdk.internal.misc.ThreadTracker;
|
||||
import jdk.internal.misc.VM;
|
||||
import sun.nio.cs.ThreadLocalCoders;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
@ -47,6 +48,7 @@ import java.util.ServiceLoader;
|
|||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -370,9 +372,17 @@ public abstract class Charset
|
|||
};
|
||||
}
|
||||
|
||||
// Thread-local gate to prevent recursive provider lookups
|
||||
private static ThreadLocal<ThreadLocal<?>> gate =
|
||||
new ThreadLocal<ThreadLocal<?>>();
|
||||
private static class ThreadTrackHolder {
|
||||
static final ThreadTracker TRACKER = new ThreadTracker();
|
||||
}
|
||||
|
||||
private static Object tryBeginLookup() {
|
||||
return ThreadTrackHolder.TRACKER.tryBegin();
|
||||
}
|
||||
|
||||
private static void endLookup(Object key) {
|
||||
ThreadTrackHolder.TRACKER.end(key);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static Charset lookupViaProviders(final String charsetName) {
|
||||
|
@ -388,12 +398,12 @@ public abstract class Charset
|
|||
if (!VM.isBooted())
|
||||
return null;
|
||||
|
||||
if (gate.get() != null)
|
||||
Object key = tryBeginLookup();
|
||||
if (key == null) {
|
||||
// Avoid recursive provider lookups
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
gate.set(gate);
|
||||
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<>() {
|
||||
public Charset run() {
|
||||
|
@ -409,7 +419,7 @@ public abstract class Charset
|
|||
});
|
||||
|
||||
} finally {
|
||||
gate.set(null);
|
||||
endLookup(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue