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)
| 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 |
nothing calls this directly
no test coverage detected