Class SemaphoreKeeperGuavaImpl<K>
java.lang.Object
org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl<K>
- All Implemented Interfaces:
SemaphoreKeeper<K>
-
Constructor Summary
-
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.
-
Constructor Details
-
SemaphoreKeeperGuavaImpl
public SemaphoreKeeperGuavaImpl(int permits, boolean fair)
-
-
Method Details
-
summonGuard
Description copied from interface:SemaphoreKeeper
Create or load semaphore for key from cache.- Specified by:
summonGuard
in interfaceSemaphoreKeeper<K>
- Parameters:
key
- semaphore identifier- Returns:
- new or existing semaphore for given key, for one key there is always only one semaphore available
-
summonGuardAndAcquire
Description copied from interface:SemaphoreKeeper
Get guard and lock for key.- Specified by:
summonGuardAndAcquire
in interfaceSemaphoreKeeper<K>
- Parameters:
key
- for which guard should be created and acquired- Returns:
- semaphore guard
-
releaseGuard
Description copied from interface:SemaphoreKeeper
Unlock and release guard.- Specified by:
releaseGuard
in interfaceSemaphoreKeeper<K>
- Parameters:
guard
- semaphore guard which should be released
-