Attempts to acquire a permit before performing a META lookup. This method should be called prior to starting a META lookup with #getClosestRowBefore. Whenever it's called we try to acquire a permit from the #meta_lookups semaphore. Because we promised a non-blocking API, we act
()
| 701 | * @return {@code true} if a permit was acquired, {@code false} otherwise. |
| 702 | */ |
| 703 | boolean acquireMetaLookupPermit() { |
| 704 | try { |
| 705 | // With such a low timeout, the JVM may chose to spin-wait instead of |
| 706 | // de-scheduling the thread (and causing context switches and whatnot). |
| 707 | return meta_lookups.tryAcquire(5, MILLISECONDS); |
| 708 | } catch (InterruptedException e) { |
| 709 | Thread.currentThread().interrupt(); // Make this someone else's problem. |
| 710 | return false; |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Releases a META lookup permit that was acquired. |
no outgoing calls