Skip to content

Commit

Permalink
Merge pull request #15667 from JasonFengJ9/eoct
Browse files Browse the repository at this point in the history
Implement Access.executeOnCarrierThread()
  • Loading branch information
tajila committed Aug 8, 2022
2 parents e94beed + 3df3260 commit 5acec46
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion jcl/src/java.base/share/classes/java/lang/Access.java
Expand Up @@ -523,7 +523,20 @@ public <T> void setCarrierThreadLocal(ThreadLocal<T> local, T value) {
}

public <V> V executeOnCarrierThread(Callable<V> task) throws Exception {
throw new UnsupportedOperationException();
V result;
Thread currentThread = Thread.currentThread();
if (currentThread.isVirtual()) {
Thread carrierThread = Thread.currentCarrierThread();
carrierThread.setCurrentThread(carrierThread);
try {
result = task.call();
} finally {
carrierThread.setCurrentThread(currentThread);
}
} else {
result = task.call();
}
return result;
}

public Continuation getContinuation(Thread thread) {
Expand Down

0 comments on commit 5acec46

Please sign in to comment.