Class AsyncSemaphore

java.lang.Object
io.temporal.internal.common.AsyncSemaphore

public final class AsyncSemaphore extends Object
A simple async semaphore. Unfortunately there's not any readily available properly licensed library I could find for this which is a bit shocking, but this implementation should be suitable for our needs.
  • Constructor Details

    • AsyncSemaphore

      public AsyncSemaphore(int initialPermits)
  • Method Details

    • acquire

      public CompletableFuture<Void> acquire()
      Acquire a permit asynchronously. If a permit is available, returns a completed future, otherwise returns a future that will be completed when a permit is released.
    • tryAcquire

      public boolean tryAcquire()
    • release

      public void release()
      Release a permit. If there are waiting futures, completes the next one instead of incrementing the permit count.