Top Fields Constructors Methods
io.rsocket.core

pack-priv final Class StateUtils

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

Field Summary

Modifier and TypeField and Description
pack-priv static final long
FIRST_FRAME_SENT_FLAG

Bit Flag that indicates that sent first initial frame was sent (in case of requester) or consumed (if responder)

pack-priv static final long
FIRST_PAYLOAD_RECEIVED_FLAG

Bit Flag that indicates that the first payload in RequestChannel scenario is received

pack-priv static final long
FLAGS_MASK

Volatile Long Field bit mask that allows extract flags stored in the field

pack-priv static final long
INBOUND_TERMINATED_FLAG

Bit Flag that indicates requestChannel stream is half terminated.

pack-priv static final long
OUTBOUND_TERMINATED_FLAG

Bit Flag that indicates requestChannel stream is half terminated.

pack-priv static final long
READY_TO_SEND_FIRST_FRAME_FLAG

Bit Flag that indicates that the logical stream is ready to send the first initial frame (applicable for requester only)

pack-priv static final long
REASSEMBLING_FLAG

Bit Flag that indicates that there is a frame being reassembled

pack-priv static final long
REQUEST_MASK

Volatile Long Field bit mask that allows extract int RequestN stored in the field

pack-priv static final long
SUBSCRIBED_FLAG

Bit Flag that indicates Requester Producer has been subscribed once

pack-priv static final long
TERMINATED_STATE

State that indicates request operator was terminated

pack-priv static final long
UNSUBSCRIBED_STATE

Initial state for any request operator

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static <T> long
addRequestN(AtomicLongFieldUpdater<T> updater, T instance, long toAdd)

pack-priv static <T> long
addRequestN(AtomicLongFieldUpdater<T> updater, T instance, long toAdd, boolean markPrepared)

pack-priv static long
addRequestN(long a, long b)

pack-priv static long
extractRequestN(long state)

pack-priv static boolean
hasRequested(long state)

pack-priv static boolean

Returns:

true if the FIRST_FRAME_SENT_FLAG flag is set
isFirstFrameSent
(long
to check whether stream is established
state
)

Indicates that the first frame which established logical stream has already been sent

pack-priv static boolean

Returns:

true if the FIRST_PAYLOAD_RECEIVED_FLAG flag is set
isFirstPayloadReceived
(long
to check whether stream is established
state
)

Indicates that the logical stream is ready for initial frame sending

pack-priv static boolean

Returns:

true if the INBOUND_TERMINATED_FLAG flag is set
isInboundTerminated
(long
to check whether it has INBOUND_TERMINATED_FLAG set
state
)

Indicates that a the inbound channel of a bidirectional stream is terminated.

pack-priv static boolean
pack-priv static boolean

Returns:

true if the OUTBOUND_TERMINATED_FLAG flag is set
isOutboundTerminated
(long
to check whether it has OUTBOUND_TERMINATED_FLAG set
state
)

Indicates that a the outbound channel of a bidirectional stream is terminated.

pack-priv static boolean

Returns:

true if the READY_TO_SEND_FIRST_FRAME_FLAG flag is set
isReadyToSendFirstFrame
(long
to check whether stream is prepared for initial frame sending
state
)

Indicates that the logical stream is ready for initial frame sending

pack-priv static boolean

Returns:

true if the REASSEMBLING_FLAG flag is set
isReassembling
(long
to check whether there is reassembly in progress
state
)

Indicates that a payload reassembly process is completed.

pack-priv static boolean

Returns:

true if the SUBSCRIBED_FLAG flag is set
isSubscribed
(long
to check whether stream is subscribed
state
)

Indicates that the given stream has already been subscribed once

pack-priv static boolean

Returns:

true if state is terminated or has flag subscribed
isSubscribedOrTerminated
(long
to check flags on
state
)

Shortcut for isSubscribed || isTerminated methods

pack-priv static boolean

Returns:

true if the OUTBOUND_TERMINATED_FLAG flag is set
isTerminated
(long
to check whether it has OUTBOUND_TERMINATED_FLAG set
state
)

Indicates that a the outbound channel of a bidirectional stream is terminated.

pack-priv static <
generic type of the instance
T
>
void
lazyTerminate(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Makes current state a TERMINATED_STATE using AtomicLongFieldUpdater#lazySet(Object, long)

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markFirstFrameSent
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Adds (if possible) to the given state the FIRST_FRAME_SENT_FLAG flag which indicates that the first frame has already set and logical stream has already been established.

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markFirstPayloadReceived
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Adds (if possible) to the given state the FIRST_PAYLOAD_RECEIVED_FLAG flag which indicates that the logical stream is ready for initial frame sending.

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markInboundTerminated
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Adds (if possible) to the given state the INBOUND_TERMINATED_FLAG flag which indicates that an inbound channel of a bidirectional stream is terminated.

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markOutboundTerminated
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
,
boolean
indicates whether FIRST_FRAME_SENT_FLAG should be checked to make final decision
checkEstablishment
)

Adds (if possible) to the given state the OUTBOUND_TERMINATED_FLAG flag which indicates that an outbound channel of a bidirectional stream is terminated.

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markReadyToSendFirstFrame
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Adds (if possible) to the given state the READY_TO_SEND_FIRST_FRAME_FLAG flag which indicates that the logical stream is ready for initial frame sending.

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markReassembled
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Removes (if possible) from the given state the REASSEMBLING_FLAG flag which indicates that a payload reassembly process is completed.

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markReassembling
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Adds (if possible) to the given state the REASSEMBLING_FLAG flag which indicates that there is a payload reassembling in progress.

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markSubscribed
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Adds (if possible) to the given state the SUBSCRIBED_FLAG flag which indicates that the given stream has already been subscribed once

Note, the flag will not be added if the stream has already been terminated or if the stream has already been subscribed once

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markSubscribed
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
,
boolean
indicates whether the given instance should be marked as prepared
markPrepared
)

Adds (if possible) to the given state the SUBSCRIBED_FLAG flag which indicates that the given stream has already been subscribed once

Note, the flag will not be added if the stream has already been terminated or if the stream has already been subscribed once

pack-priv static <
generic type of the instance
T
>
long

Returns:

return previous state before setting the new one
markTerminated
(AtomicLongFieldUpdater<T>
of the volatile state field
updater
,
T
instance holder of the volatile state
instance
)

Makes current state a TERMINATED_STATE

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FIRST_FRAME_SENT_FLAGback to summary
pack-priv static final long FIRST_FRAME_SENT_FLAG

Bit Flag that indicates that sent first initial frame was sent (in case of requester) or consumed (if responder)

FIRST_PAYLOAD_RECEIVED_FLAGback to summary
pack-priv static final long FIRST_PAYLOAD_RECEIVED_FLAG

Bit Flag that indicates that the first payload in RequestChannel scenario is received

FLAGS_MASKback to summary
pack-priv static final long FLAGS_MASK

Volatile Long Field bit mask that allows extract flags stored in the field

INBOUND_TERMINATED_FLAGback to summary
pack-priv static final long INBOUND_TERMINATED_FLAG

Bit Flag that indicates requestChannel stream is half terminated. In this case flag indicates that the inbound is terminated

OUTBOUND_TERMINATED_FLAGback to summary
pack-priv static final long OUTBOUND_TERMINATED_FLAG

Bit Flag that indicates requestChannel stream is half terminated. In this case flag indicates that the outbound is terminated

READY_TO_SEND_FIRST_FRAME_FLAGback to summary
pack-priv static final long READY_TO_SEND_FIRST_FRAME_FLAG

Bit Flag that indicates that the logical stream is ready to send the first initial frame (applicable for requester only)

REASSEMBLING_FLAGback to summary
pack-priv static final long REASSEMBLING_FLAG

Bit Flag that indicates that there is a frame being reassembled

REQUEST_MASKback to summary
pack-priv static final long REQUEST_MASK

Volatile Long Field bit mask that allows extract int RequestN stored in the field

SUBSCRIBED_FLAGback to summary
pack-priv static final long SUBSCRIBED_FLAG

Bit Flag that indicates Requester Producer has been subscribed once

TERMINATED_STATEback to summary
pack-priv static final long TERMINATED_STATE

State that indicates request operator was terminated

UNSUBSCRIBED_STATEback to summary
pack-priv static final long UNSUBSCRIBED_STATE

Initial state for any request operator

Constructor Detail

StateUtilsback to summary
pack-priv StateUtils()

Method Detail

addRequestNback to summary
pack-priv static <T> long addRequestN(AtomicLongFieldUpdater<T> updater, T instance, long toAdd)
addRequestNback to summary
pack-priv static <T> long addRequestN(AtomicLongFieldUpdater<T> updater, T instance, long toAdd, boolean markPrepared)
addRequestNback to summary
pack-priv static long addRequestN(long a, long b)
extractRequestNback to summary
pack-priv static long extractRequestN(long state)
hasRequestedback to summary
pack-priv static boolean hasRequested(long state)
isFirstFrameSentback to summary
pack-priv static boolean isFirstFrameSent(long state)

Indicates that the first frame which established logical stream has already been sent

Parameters
state:long

to check whether stream is established

Returns:boolean

true if the FIRST_FRAME_SENT_FLAG flag is set

isFirstPayloadReceivedback to summary
pack-priv static boolean isFirstPayloadReceived(long state)

Indicates that the logical stream is ready for initial frame sending

Parameters
state:long

to check whether stream is established

Returns:boolean

true if the FIRST_PAYLOAD_RECEIVED_FLAG flag is set

isInboundTerminatedback to summary
pack-priv static boolean isInboundTerminated(long state)

Indicates that a the inbound channel of a bidirectional stream is terminated.

Parameters
state:long

to check whether it has INBOUND_TERMINATED_FLAG set

Returns:boolean

true if the INBOUND_TERMINATED_FLAG flag is set

isMaxAllowedRequestNback to summary
pack-priv static boolean isMaxAllowedRequestN(long n)
isOutboundTerminatedback to summary
pack-priv static boolean isOutboundTerminated(long state)

Indicates that a the outbound channel of a bidirectional stream is terminated.

Parameters
state:long

to check whether it has OUTBOUND_TERMINATED_FLAG set

Returns:boolean

true if the OUTBOUND_TERMINATED_FLAG flag is set

isReadyToSendFirstFrameback to summary
pack-priv static boolean isReadyToSendFirstFrame(long state)

Indicates that the logical stream is ready for initial frame sending

Parameters
state:long

to check whether stream is prepared for initial frame sending

Returns:boolean

true if the READY_TO_SEND_FIRST_FRAME_FLAG flag is set

isReassemblingback to summary
pack-priv static boolean isReassembling(long state)

Indicates that a payload reassembly process is completed.

Parameters
state:long

to check whether there is reassembly in progress

Returns:boolean

true if the REASSEMBLING_FLAG flag is set

isSubscribedback to summary
pack-priv static boolean isSubscribed(long state)

Indicates that the given stream has already been subscribed once

Parameters
state:long

to check whether stream is subscribed

Returns:boolean

true if the SUBSCRIBED_FLAG flag is set

isSubscribedOrTerminatedback to summary
pack-priv static boolean isSubscribedOrTerminated(long state)

Shortcut for isSubscribed || isTerminated methods

Parameters
state:long

to check flags on

Returns:boolean

true if state is terminated or has flag subscribed

isTerminatedback to summary
pack-priv static boolean isTerminated(long state)

Indicates that a the outbound channel of a bidirectional stream is terminated.

Parameters
state:long

to check whether it has OUTBOUND_TERMINATED_FLAG set

Returns:boolean

true if the OUTBOUND_TERMINATED_FLAG flag is set

lazyTerminateback to summary
pack-priv static <T> void lazyTerminate(AtomicLongFieldUpdater<T> updater, T instance)

Makes current state a TERMINATED_STATE using AtomicLongFieldUpdater#lazySet(Object, long)

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

markFirstFrameSentback to summary
pack-priv static <T> long markFirstFrameSent(AtomicLongFieldUpdater<T> updater, T instance)

Adds (if possible) to the given state the FIRST_FRAME_SENT_FLAG flag which indicates that the first frame has already set and logical stream has already been established.

Note, the flag will not be added if the stream has already been terminated or if the stream has already been established once

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

Returns:long

return previous state before setting the new one

markFirstPayloadReceivedback to summary
pack-priv static <T> long markFirstPayloadReceived(AtomicLongFieldUpdater<T> updater, T instance)

Adds (if possible) to the given state the FIRST_PAYLOAD_RECEIVED_FLAG flag which indicates that the logical stream is ready for initial frame sending.

Note, the flag will not be added if the stream has already been terminated or if the stream has already been marked as prepared

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

Returns:long

return previous state before setting the new one

markInboundTerminatedback to summary
pack-priv static <T> long markInboundTerminated(AtomicLongFieldUpdater<T> updater, T instance)

Adds (if possible) to the given state the INBOUND_TERMINATED_FLAG flag which indicates that an inbound channel of a bidirectional stream is terminated.

Note

, this action will have no effect if the stream has already been terminated or if the INBOUND_TERMINATED_FLAG flag has already been set

Note

, if the outbound stream has already been terminated, then the result state will be TERMINATED_STATE

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

Returns:long

return previous state before setting the new one

markOutboundTerminatedback to summary
pack-priv static <T> long markOutboundTerminated(AtomicLongFieldUpdater<T> updater, T instance, boolean checkEstablishment)

Adds (if possible) to the given state the OUTBOUND_TERMINATED_FLAG flag which indicates that an outbound channel of a bidirectional stream is terminated.

Note

, this action will have no effect if the stream has already been terminated or if the OUTBOUND_TERMINATED_FLAG flag has already been set

Note

, if the checkEstablishment parameter is true and the logical stream is not established, then the result state will be TERMINATED_STATE
Note, if the inbound stream has already been terminated, then the result state will be TERMINATED_STATE

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

checkEstablishment:boolean

indicates whether FIRST_FRAME_SENT_FLAG should be checked to make final decision

Returns:long

return previous state before setting the new one

markReadyToSendFirstFrameback to summary
pack-priv static <T> long markReadyToSendFirstFrame(AtomicLongFieldUpdater<T> updater, T instance)

Adds (if possible) to the given state the READY_TO_SEND_FIRST_FRAME_FLAG flag which indicates that the logical stream is ready for initial frame sending.

Note, the flag will not be added if the stream has already been terminated or if the stream has already been marked as prepared

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

Returns:long

return previous state before setting the new one

markReassembledback to summary
pack-priv static <T> long markReassembled(AtomicLongFieldUpdater<T> updater, T instance)

Removes (if possible) from the given state the REASSEMBLING_FLAG flag which indicates that a payload reassembly process is completed.

Note, the flag will not be removed if the stream has already been terminated

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

Returns:long

return previous state before setting the new one

markReassemblingback to summary
pack-priv static <T> long markReassembling(AtomicLongFieldUpdater<T> updater, T instance)

Adds (if possible) to the given state the REASSEMBLING_FLAG flag which indicates that there is a payload reassembling in progress.

Note, the flag will not be added if the stream has already been terminated

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

Returns:long

return previous state before setting the new one

markSubscribedback to summary
pack-priv static <T> long markSubscribed(AtomicLongFieldUpdater<T> updater, T instance)

Adds (if possible) to the given state the SUBSCRIBED_FLAG flag which indicates that the given stream has already been subscribed once

Note, the flag will not be added if the stream has already been terminated or if the stream has already been subscribed once

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

Returns:long

return previous state before setting the new one

markSubscribedback to summary
pack-priv static <T> long markSubscribed(AtomicLongFieldUpdater<T> updater, T instance, boolean markPrepared)

Adds (if possible) to the given state the SUBSCRIBED_FLAG flag which indicates that the given stream has already been subscribed once

Note, the flag will not be added if the stream has already been terminated or if the stream has already been subscribed once

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

markPrepared:boolean

indicates whether the given instance should be marked as prepared

Returns:long

return previous state before setting the new one

markTerminatedback to summary
pack-priv static <T> long markTerminated(AtomicLongFieldUpdater<T> updater, T instance)

Makes current state a TERMINATED_STATE

Parameters
<T>
generic type of the instance
updater:AtomicLongFieldUpdater<T>

of the volatile state field

instance:T

instance holder of the volatile state

Returns:long

return previous state before setting the new one