Top Description Fields Constructors Methods
jdk.internal.net.http.common

public final Class Demand

extends Object
Class Inheritance
Imports
java.util.concurrent.atomic.AtomicLong

Encapsulates operations with demand (Reactive Streams).

Demand is the aggregated number of elements requested by a Subscriber which is yet to be delivered (fulfilled) by the Publisher.

Field Summary

Modifier and TypeField and Description
private final AtomicLong

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

a value m (0 <= m <= n) this demand has been actually decreased by
decreaseAndGet
(long
decrement > 0
n
)

Tries to decrease this demand by the specified positive value.

public long

Returns:

the current value of this demand
get
()

Returns the current value of this demand.

public boolean

Returns:

true iff prior to this operation this demand was fulfilled
increase
(long
increment > 0
n
)

Increases this demand by the specified positive value.

public boolean

Returns:

true if the demand was increased, false otherwise.
increaseIfFulfilled
()

Increases this demand by 1 but only if it is fulfilled.

public boolean

Returns:

true iff there is no unfulfilled demand
isFulfilled
()

public void
reset()

Resets this object to its initial state.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public boolean

Returns:

true iff this demand has been decreased by 1
tryDecrement
()

Tries to decrease this demand by 1.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

valback to summary
private final AtomicLong val

Constructor Detail

Demandback to summary
public Demand()

Method Detail

decreaseAndGetback to summary
public long decreaseAndGet(long n)

Tries to decrease this demand by the specified positive value.

The actual value this demand has been decreased by might be less than n, including 0 (no decrease at all).

Parameters
n:long

decrement > 0

Returns:long

a value m (0 <= m <= n) this demand has been actually decreased by

getback to summary
public long get()

Returns the current value of this demand.

Returns:long

the current value of this demand

increaseback to summary
public boolean increase(long n)

Increases this demand by the specified positive value.

Parameters
n:long

increment > 0

Returns:boolean

true iff prior to this operation this demand was fulfilled

increaseIfFulfilledback to summary
public boolean increaseIfFulfilled()

Increases this demand by 1 but only if it is fulfilled.

Returns:boolean

true if the demand was increased, false otherwise.

isFulfilledback to summary
public boolean isFulfilled()
Returns:boolean

true iff there is no unfulfilled demand

resetback to summary
public void reset()

Resets this object to its initial state.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
tryDecrementback to summary
public boolean tryDecrement()

Tries to decrease this demand by 1.

Returns:boolean

true iff this demand has been decreased by 1