Skip to content

Commit

Permalink
Rename nonce/nounce to seqNo in VirtualThread class
Browse files Browse the repository at this point in the history
  • Loading branch information
pchilano committed Oct 24, 2024
1 parent 13353fd commit d40d382
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/java.base/share/classes/java/lang/VirtualThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -628,15 +628,15 @@ private void afterYield() {

// Object.wait
if (s == WAITING || s == TIMED_WAITING) {
byte nonce;
byte seqNo;
int newState;
if (s == WAITING) {
nonce = 0; // not used
seqNo = 0; // not used
setState(newState = WAIT);
} else {
// synchronize with timeout task (previous timed-wait may be running)
synchronized (timedWaitLock()) {
nonce = ++timedWaitSeqNo;
seqNo = ++timedWaitSeqNo;
setState(newState = TIMED_WAIT);
}
}
Expand All @@ -659,7 +659,7 @@ private void afterYield() {
// schedule wakeup
if (newState == TIMED_WAIT) {
assert waitTimeout > 0;
waitTimeoutTask = schedule(() -> waitTimeoutExpired(nonce), waitTimeout, MILLISECONDS);
waitTimeoutTask = schedule(() -> waitTimeoutExpired(seqNo), waitTimeout, MILLISECONDS);
}
return;
}
Expand Down Expand Up @@ -945,12 +945,12 @@ private void unblock() {
* and submit its task so that it continues and attempts to reenter the monitor.
* This method does nothing if the thread has been woken by notify or interrupt.
*/
private void waitTimeoutExpired(byte nounce) {
private void waitTimeoutExpired(byte seqNo) {
assert !Thread.currentThread().isVirtual();
for (;;) {
boolean unblocked = false;
synchronized (timedWaitLock()) {
if (nounce != timedWaitSeqNo) {
if (seqNo != timedWaitSeqNo) {
// this timeout task is for a past timed-wait
return;
}
Expand Down Expand Up @@ -1394,7 +1394,7 @@ private Object carrierThreadAccessLock() {
}

/**
* Returns a lock object to coordinating timed-wait setup and timeout handling.
* Returns a lock object for coordinating timed-wait setup and timeout handling.
*/
private Object timedWaitLock() {
// use this object for now to avoid the overhead of introducing another lock
Expand Down

0 comments on commit d40d382

Please sign in to comment.