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

Method tryEnterIf

output/java_guava/1.4.17/Monitor.java:732–748  ·  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

730
731
732 public boolean tryEnterIf(Guard guard) {
733 if (guard.monitor != this) {
734 throw new IllegalMonitorStateException();
735 }
736 final ReentrantLock lock = this.lock;
737 if (!lock.tryLock()) {
738 return false;
739 }
740 boolean satisfied = false;
741 try {
742 return satisfied = guard.isSatisfied();
743 } finally {
744 if (!satisfied) {
745 lock.unlock();
746 }
747 }
748 }
749
750 /**
751 * 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