Enters this monitor when the guard is satisfied. Blocks indefinitely, but may be interrupted. @throws InterruptedException if interrupted while waiting
(Guard guard)
| 451 | |
| 452 | |
| 453 | public void enterWhen(Guard guard) throws InterruptedException { |
| 454 | if (guard.monitor != this) { |
| 455 | throw new IllegalMonitorStateException(); |
| 456 | } |
| 457 | final ReentrantLock lock = this.lock; |
| 458 | boolean signalBeforeWaiting = lock.isHeldByCurrentThread(); |
| 459 | lock.lockInterruptibly(); |
| 460 | boolean satisfied = false; |
| 461 | try { |
| 462 | if (!guard.isSatisfied()) { |
| 463 | await(guard, signalBeforeWaiting); |
| 464 | } |
| 465 | satisfied = true; |
| 466 | } finally { |
| 467 | if (!satisfied) { |
| 468 | leave(); |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Enters this monitor when the guard is satisfied. Blocks indefinitely. |
nothing calls this directly
no test coverage detected