Interface SemaphoreProvider

  • All Known Implementing Classes:
    DefaultSemaphoreProvider

    public interface SemaphoreProvider
    Simple interface to provide shared access to a Semaphore.
    Author:
    Kelly Tisdell
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Semaphore create​(com.broadleafcommerce.search.api.type.IndexableType type)
      Creates a semaphore with zero permits.
      Semaphore create​(com.broadleafcommerce.search.api.type.IndexableType type, int permits)
      Creates a semaphore with the given permits.
      void destroy​(com.broadleafcommerce.search.api.type.IndexableType type)
      Removes the semaphore from the local registry.
      Optional<Semaphore> getCurrentSemaphore​(com.broadleafcommerce.search.api.type.IndexableType type)
      Looks for an existing semaphore and returns it if available.
    • Method Detail

      • create

        Semaphore create​(com.broadleafcommerce.search.api.type.IndexableType type)
        Creates a semaphore with zero permits.
        Parameters:
        type - the indexable type for which to create a new Semaphore
        Returns:
        the newly created Semaphore
        Throws:
        IllegalStateException - if a semaphore has already been created for the IndexableType
      • create

        Semaphore create​(com.broadleafcommerce.search.api.type.IndexableType type,
                         int permits)
        Creates a semaphore with the given permits.
        Parameters:
        type - the indexable type for which to create a new Semaphore
        permits - the number of permits for the new Semaphore
        Returns:
        the newly created Semaphore
        Throws:
        IllegalStateException - if a semaphore has already been created for the IndexableType
      • getCurrentSemaphore

        Optional<Semaphore> getCurrentSemaphore​(com.broadleafcommerce.search.api.type.IndexableType type)
        Looks for an existing semaphore and returns it if available.
        Parameters:
        type - the indexable type for which to get the semaphore
        Returns:
        if present, the semaphore for the given indexable type
      • destroy

        void destroy​(com.broadleafcommerce.search.api.type.IndexableType type)
        Removes the semaphore from the local registry.
        Parameters:
        type - the indexable type for which to destroy the semaphore