@@ -103,24 +103,27 @@ private void waitInternal(DynamicObject conditionVariable, ReentrantLock mutexLo
103
103
// If there is an interrupt, it should be consumed by condition.await() and the Ruby Thread sleep status
104
104
// must imply being ready to be interrupted by Thread#{run,wakeup}.
105
105
condLock .lock ();
106
- mutexLock .unlock ();
107
-
108
- Layouts .CONDITION_VARIABLE
109
- .setWaiters (conditionVariable , Layouts .CONDITION_VARIABLE .getWaiters (conditionVariable ) + 1 );
110
106
try {
111
- awaitSignal (conditionVariable , thread , durationInNanos , condLock , condition , endNanoTime );
112
- } catch (Error | RuntimeException e ) {
113
- /*
114
- * Consume a signal if one was waiting. We do this because the error may have
115
- * occurred while we were waiting, or at some point after exiting a safepoint that
116
- * throws an exception and another thread has attempted to signal us. It is valid
117
- * for us to consume this signal because we are still marked as waiting for it.
118
- */
119
- consumeSignal (conditionVariable );
120
- throw e ;
121
- } finally {
107
+ mutexLock .unlock ();
108
+
122
109
Layouts .CONDITION_VARIABLE
123
- .setWaiters (conditionVariable , Layouts .CONDITION_VARIABLE .getWaiters (conditionVariable ) - 1 );
110
+ .setWaiters (conditionVariable , Layouts .CONDITION_VARIABLE .getWaiters (conditionVariable ) + 1 );
111
+ try {
112
+ awaitSignal (conditionVariable , thread , durationInNanos , condLock , condition , endNanoTime );
113
+ } catch (Error | RuntimeException e ) {
114
+ /*
115
+ * Consume a signal if one was waiting. We do this because the error may have
116
+ * occurred while we were waiting, or at some point after exiting a safepoint that
117
+ * throws an exception and another thread has attempted to signal us. It is valid
118
+ * for us to consume this signal because we are still marked as waiting for it.
119
+ */
120
+ consumeSignal (conditionVariable );
121
+ throw e ;
122
+ } finally {
123
+ Layouts .CONDITION_VARIABLE
124
+ .setWaiters (conditionVariable , Layouts .CONDITION_VARIABLE .getWaiters (conditionVariable ) - 1 );
125
+ }
126
+ } finally {
124
127
condLock .unlock ();
125
128
MutexOperations .internalLockEvenWithException (mutexLock , this , getContext ());
126
129
}
0 commit comments