@Internal public interface AvailabilityProvider
CompletableFuture
. For usage check out for example PullingAsyncDataInput
.Modifier and Type | Interface and Description |
---|---|
static class |
AvailabilityProvider.AvailabilityHelper
A availability implementation for providing the helpful functions of resetting the
available/unavailable states.
|
Modifier and Type | Field and Description |
---|---|
static CompletableFuture<?> |
AVAILABLE
Constant that allows to avoid volatile checks
CompletableFuture.isDone() . |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<?> |
getAvailableFuture() |
default boolean |
isApproximatelyAvailable()
Checks whether this instance is available only via constant
AVAILABLE to avoid
performance concern caused by volatile access in CompletableFuture.isDone() . |
default boolean |
isAvailable()
In order to best-effort avoid volatile access in
CompletableFuture.isDone() , we check the condition
of future == AVAILABLE firstly for getting probable performance benefits while hot looping. |
static final CompletableFuture<?> AVAILABLE
CompletableFuture.isDone()
. Check
isAvailable()
and isApproximatelyAvailable()
for more explanation.CompletableFuture<?> getAvailableFuture()
default boolean isAvailable()
CompletableFuture.isDone()
, we check the condition
of future == AVAILABLE
firstly for getting probable performance benefits while hot looping.
It is always safe to use this method in performance nonsensitive scenarios to get the precise state.
default boolean isApproximatelyAvailable()
AVAILABLE
to avoid
performance concern caused by volatile access in CompletableFuture.isDone()
. So it is
mainly used in the performance sensitive scenarios which do not always need the precise state.
This method is still safe to get the precise state if getAvailableFuture()
was touched via (.get(), .wait(), .isDone(), ...) before, which also has a "happen-before"
relationship with this call.
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.