File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ boolean tryLock() {
167167 if (r < 0 ) { // overflow
168168 throw new Error ("Maximum lock count exceeded" );
169169 }
170+ // Note: protected by monitor and not required to be observable, no ordering needed
170171 acquisitions = r ;
171172 return true ;
172173 }
@@ -187,6 +188,7 @@ protected boolean tryRelease(long releases) {
187188 acquisitions = 1 ;
188189 setState (0 );
189190 } else {
191+ // Note: protected by monitor and not required to be observable, no ordering needed
190192 assert releases < acquisitions ;
191193 acquisitions -= (int ) releases ;
192194 }
Original file line number Diff line number Diff line change @@ -153,10 +153,11 @@ protected final void setState(long newState) {
153153 * For {@linkplain JavaMonitorConditionObject#await conditional waiting}, returns the number of
154154 * acquisitions, which is subsequently passed to {@link #tryRelease} to entirely release
155155 * ownership, and later to {@link #tryAcquire} to regain ownership after waiting.
156+ *
157+ * While {@code AbstractQueuedLongSynchronizer} calls {@link #getState()} assuming that it
158+ * encodes the acquisition count, this method allows for more flexibility in implementations.
156159 */
157- protected long getAcquisitions () {
158- return getState ();
159- }
160+ protected abstract long getAcquisitions ();
160161
161162 // see AbstractQueuedLongSynchronizer.compareAndSetState(long, long)
162163 @ Uninterruptible (reason = "Called from uninterruptible code." , mayBeInlined = true )
@@ -341,7 +342,7 @@ private int cancelAcquire(Node node) {
341342 protected abstract boolean tryAcquire (long arg );
342343
343344 // see AbstractQueuedLongSynchronizer.tryRelease(long)
344- protected abstract boolean tryRelease (long releases );
345+ protected abstract boolean tryRelease (long arg );
345346
346347 // see AbstractQueuedLongSynchronizer.isHeldExclusively()
347348 protected abstract boolean isHeldExclusively ();
You can’t perform that action at this time.
0 commit comments