Interface SemaphoreKeeper<K>
- Type Parameters:
K
- key type
- All Known Implementing Classes:
SemaphoreKeeperGuavaImpl
public interface SemaphoreKeeper<K>
Key based semaphore provider.
For the same key there is always only one semaphore available. Unused semaphores are garbage-collect.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
releaseGuard
(@Nullable Semaphore guard) Unlock and release guard.summonGuard
(@NonNull K key) Create or load semaphore for key from cache.summonGuardAndAcquire
(@NonNull K key) Get guard and lock for key.
-
Method Details
-
summonGuard
Create or load semaphore for key from cache.- Parameters:
key
- semaphore identifier- Returns:
- new or existing semaphore for given key, for one key there is always only one semaphore available
-
summonGuardAndAcquire
Get guard and lock for key.- Parameters:
key
- for which guard should be created and acquired- Returns:
- semaphore guard
-
releaseGuard
Unlock and release guard.- Parameters:
guard
- semaphore guard which should be released
-