src/java.base/share/classes/java/util/concurrent/locks/ReentrantLock.java

Print this page

        

*** 35,44 **** --- 35,45 ---- package java.util.concurrent.locks; import java.util.Collection; import java.util.concurrent.TimeUnit; + import jdk.internal.vm.annotation.ReservedStackAccess; /** * A reentrant mutual exclusion {@link Lock} with the same basic * behavior and semantics as the implicit monitor lock accessed using * {@code synchronized} methods and statements, but with extended
*** 125,134 **** --- 126,136 ---- /** * Performs non-fair tryLock. tryAcquire is implemented in * subclasses, but both need nonfair try for trylock method. */ + @ReservedStackAccess final boolean nonfairTryAcquire(int acquires) { final Thread current = Thread.currentThread(); int c = getState(); if (c == 0) { if (compareAndSetState(0, acquires)) {
*** 144,153 **** --- 146,156 ---- return true; } return false; } + @ReservedStackAccess protected final boolean tryRelease(int releases) { int c = getState() - releases; if (Thread.currentThread() != getExclusiveOwnerThread()) throw new IllegalMonitorStateException(); boolean free = false;
*** 201,210 **** --- 204,214 ---- /** * Performs lock. Try immediate barge, backing up to normal * acquire on failure. */ + @ReservedStackAccess final void lock() { if (compareAndSetState(0, 1)) setExclusiveOwnerThread(Thread.currentThread()); else acquire(1);
*** 227,236 **** --- 231,241 ---- /** * Fair version of tryAcquire. Don't grant access unless * recursive call or no waiters or is first. */ + @ReservedStackAccess protected final boolean tryAcquire(int acquires) { final Thread current = Thread.currentThread(); int c = getState(); if (c == 0) { if (!hasQueuedPredecessors() &&