Class UnboundedSemaphore


  • public final class UnboundedSemaphore
    extends Object
    The UnboundedSemaphore is designed to fit Reactive Streams use-case; that is to be able to allow an unbounded number of acquires once a cumulative release count reaches Long.MAX_VALUE. For details, refer to release(long) and tryAcquire() methods where specifics of this semaphore are explained in detail.
    See Also:
    Reactive Streams 3.17
    • Method Detail

      • tryAcquire

        public long tryAcquire()
        In a non-blocking manner, try to acquire a single permit.
        Returns:
        original number of permits in this semaphore; if 0 is returned, the requester didn't obtain a permit. In case a Long.MAX_VALUE is returned, the requester is informed that this semaphore is unbounded and that any further acquire will be always successful.
      • create

        public static UnboundedSemaphore create()
        Create a new instance.
        Returns:
        UnboundedSemaphore