Skip to content

Commit

Permalink
Return from park immediately for non-positive time since epoch
Browse files Browse the repository at this point in the history
Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
theresa-m committed Dec 11, 2024
1 parent 2aa906a commit 42ce9ec
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions runtime/vm/threadpark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,24 @@ threadParkImpl(J9VMThread *vmThread, BOOLEAN timeoutIsEpochRelative, I_64 timeou
J9JavaVM *vm = vmThread->javaVM;

/* Trc_JCL_park_Entry(vmThread, timeoutIsEpochRelative, timeout); */
if ((0 != timeout) || (timeoutIsEpochRelative)) {
if ((0 != timeout) || timeoutIsEpochRelative) {
if (timeoutIsEpochRelative) {
/* Currently, the omrthread layer provides no direct support for absolute timeouts.
* Simulate the timeout by calculating the delta from the current time.
*/
PORT_ACCESS_FROM_VMC(vmThread);
I_64 timeNow = j9time_current_time_millis();
if (timeout <= 0) {
rc = J9THREAD_TIMED_OUT;
} else {
/* Currently, the omrthread layer provides no direct support for absolute timeouts.
* Simulate the timeout by calculating the delta from the current time.
*/
PORT_ACCESS_FROM_VMC(vmThread);
I_64 timeNow = j9time_current_time_millis();

millis = timeout - timeNow;
nanos = 0;
millis = timeout - timeNow;
nanos = 0;

if (millis <= 0) {
rc = J9THREAD_TIMED_OUT;
/*Trc_JCL_park_timeIsInPast(vmThread, timeNow);*/
if (millis <= 0) {
rc = J9THREAD_TIMED_OUT;
/* Trc_JCL_park_timeIsInPast(vmThread, timeNow); */
}
}
} else {
millis = timeout / oneMillion;
Expand Down

0 comments on commit 42ce9ec

Please sign in to comment.