Package com.offbynull.coroutines.user
Class CoroutineReader
java.lang.Object
com.offbynull.coroutines.user.CoroutineReader
Reads in (deserializes) the state of a
CoroutineRunner
object.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Coroutine deserializer.static final class
Default implementation ofCoroutineReader.CoroutineDeserializer
(uses Java's built-in serialization mechanism). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CoroutineReader.CoroutineDeserializer
private final Map
private final Map
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct aCoroutineReader
object.CoroutineReader
(CoroutineReader.CoroutineDeserializer deserializer, SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineReader
object.CoroutineReader
(SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineReader
.CoroutineReader
(SerializedState.FrameUpdatePoint[] frameUpdatePoints) Constructs aCoroutineReader
.CoroutineReader
(SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineReader
. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
placeContinuationReferences
(int[] continuationIndexes, Object[] objects, Continuation cn) read
(byte[] data) Deserializes aCoroutineRunner
object from a byte array.reconstruct
(SerializedState state) Reconstructs aCoroutineRunner
object from a serializable state.
-
Field Details
-
deserializer
-
updatersMap
-
interceptersMap
-
-
Constructor Details
-
CoroutineReader
public CoroutineReader()Construct aCoroutineReader
object. Equivalent to callingnew CoroutineReader(new DefaultCoroutineDeserializer(), new FrameUpdatePoint[0], new FrameInterceptPoint[0])
. -
CoroutineReader
Constructs aCoroutineReader
. Equivalent to callingnew CoroutineReader(new DefaultCoroutineDeserializer(), frameUpdatePoints, new FrameInterceptPoint[0])
.- Parameters:
frameUpdatePoints
- frame update points- Throws:
IllegalArgumentException
- ifframeUpdatePoints
contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint)NullPointerException
- if any argument isnull
-
CoroutineReader
Constructs aCoroutineReader
. Equivalent to callingnew CoroutineReader(new DefaultCoroutineDeserializer(), new FrameUpdatePoint[0], frameInterceptPoints)
.- Parameters:
frameInterceptPoints
- frame intercept points- Throws:
IllegalArgumentException
- ifframeInterceptPoints
contains more than one entry for the same identifier (className/methodId/continuationPoint)NullPointerException
- if any argument isnull
-
CoroutineReader
public CoroutineReader(SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineReader
. Equivalent to callingnew CoroutineReader(new DefaultCoroutineDeserializer(), frameUpdatePoints, frameInterceptPoints)
.- Parameters:
frameUpdatePoints
- frame update pointsframeInterceptPoints
- frame intercept points- Throws:
IllegalArgumentException
- ifframeUpdatePoints
contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint), or ifframeInterceptPoints
contains more than one entry for the same identifier (className/methodId/continuationPoint)NullPointerException
- if any argument isnull
-
CoroutineReader
public CoroutineReader(CoroutineReader.CoroutineDeserializer deserializer, SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineReader
object.- Parameters:
deserializer
- deserializer to write out the coroutine stateframeUpdatePoints
- frame update pointsframeInterceptPoints
- frame intercept points- Throws:
NullPointerException
- if any argument isnull
or containsnull
IllegalArgumentException
- ifframeUpdatePoints
contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint), or ifframeInterceptPoints
contains more than one entry for the same identifier (className/methodId/continuationPoint)
-
-
Method Details
-
read
Deserializes aCoroutineRunner
object from a byte array.If you're handling your own deserialization and you simply want to reconstruct the deserialized object to the
CoroutineRunner
, usereconstruct(com.offbynull.coroutines.user.SerializedState)
.- Parameters:
data
- byte array to deserialize- Returns:
data
deserialized to aCoroutineRunner
object- Throws:
NullPointerException
- if any argument isnull
IllegalArgumentException
- if failed to deserialize or deserialized to a state for an unrecognized method (e.g. a method that's state is being deserialized for was changed but noSerializedState.FrameUpdatePoint
was provided to this class's constructor to handle the changes)
-
reconstruct
Reconstructs aCoroutineRunner
object from a serializable state.- Parameters:
state
- serialized state to reconstruct- Returns:
- reconstructed
CoroutineRunner
- Throws:
NullPointerException
- if any argument isnull
IllegalArgumentException
- ifstate
contains a reference / was updated to contain a reference to an unrecognized method (e.g. a method that's state is being reconstructed for was changed but noSerializedState.FrameUpdatePoint
was provided to this class's constructor to handle the changes)
-
placeContinuationReferences
private void placeContinuationReferences(int[] continuationIndexes, Object[] objects, Continuation cn)
-