MCPcopy Create free account
hub / github.com/antlr/codebuff / tryEnterIf

Method tryEnterIf

output/java_guava/1.4.19/Monitor.java:730–746  ·  view source on GitHub ↗

Enters this monitor if it is possible to do so immediately and the guard is satisfied. Does not block acquiring the lock and does not wait for the guard to be satisfied. Note: This method disregards the fairness setting of this monitor. @return whether the monitor was entered, which guar

(Guard guard)

Source from the content-addressed store, hash-verified

728
729
730 public boolean tryEnterIf(Guard guard) {
731 if (guard.monitor != this) {
732 throw new IllegalMonitorStateException();
733 }
734 final ReentrantLock lock = this.lock;
735 if (!lock.tryLock()) {
736 return false;
737 }
738 boolean satisfied = false;
739 try {
740 return satisfied = guard.isSatisfied();
741 } finally {
742 if (!satisfied) {
743 lock.unlock();
744 }
745 }
746 }
747
748 /**
749 * Waits for the guard to be satisfied. Waits indefinitely, but may be interrupted. May be called

Callers

nothing calls this directly

Calls 3

tryLockMethod · 0.45
isSatisfiedMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected