Class SemaphoreKeeperGuavaImpl<K>

    • Constructor Detail

      • SemaphoreKeeperGuavaImpl

        public SemaphoreKeeperGuavaImpl​(int permits,
                                        boolean fair)
    • Method Detail

      • summonGuard

        public Semaphore summonGuard​(@NonNull K key)
        Description copied from interface: SemaphoreKeeper
        Create or load semaphore for key from cache.
        Specified by:
        summonGuard in interface SemaphoreKeeper<K>
        Parameters:
        key - semaphore identifier
        Returns:
        new or existing semaphore for given key, for one key there is always only one semaphore available
      • summonGuardAndAcquire

        public Semaphore summonGuardAndAcquire​(@NonNull K key)
        Description copied from interface: SemaphoreKeeper
        Get guard and lock for key.
        Specified by:
        summonGuardAndAcquire in interface SemaphoreKeeper<K>
        Parameters:
        key - for which guard should be created and acquired
        Returns:
        semaphore guard
      • releaseGuard

        public void releaseGuard​(@Nullable Semaphore guard)
        Description copied from interface: SemaphoreKeeper
        Unlock and release guard.
        Specified by:
        releaseGuard in interface SemaphoreKeeper<K>
        Parameters:
        guard - semaphore guard which should be released