Package io.helidon.common.reactive
Class UnboundedSemaphore
- java.lang.Object
-
- io.helidon.common.reactive.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 reachesLong.MAX_VALUE
. For details, refer torelease(long)
andtryAcquire()
methods where specifics of this semaphore are explained in detail.- See Also:
- Reactive Streams 3.17
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static UnboundedSemaphore
create()
Create a new instance.long
tryAcquire()
In a non-blocking manner, try to acquire a single permit.
-
-
-
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 aLong.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
-
-