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 interfaceCoroutine deserializer.static final classDefault implementation ofCoroutineReader.CoroutineDeserializer(uses Java's built-in serialization mechanism). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CoroutineReader.CoroutineDeserializerprivate final Mapprivate final Map -
Constructor Summary
ConstructorsConstructorDescriptionConstruct aCoroutineReaderobject.CoroutineReader(CoroutineReader.CoroutineDeserializer deserializer, SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineReaderobject.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 voidplaceContinuationReferences(int[] continuationIndexes, Object[] objects, Continuation cn) read(byte[] data) Deserializes aCoroutineRunnerobject from a byte array.reconstruct(SerializedState state) Reconstructs aCoroutineRunnerobject from a serializable state.
-
Field Details
-
deserializer
-
updatersMap
-
interceptersMap
-
-
Constructor Details
-
CoroutineReader
public CoroutineReader()Construct aCoroutineReaderobject. 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- ifframeUpdatePointscontains 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- ifframeInterceptPointscontains 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- ifframeUpdatePointscontains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint), or ifframeInterceptPointscontains 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 aCoroutineReaderobject.- Parameters:
deserializer- deserializer to write out the coroutine stateframeUpdatePoints- frame update pointsframeInterceptPoints- frame intercept points- Throws:
NullPointerException- if any argument isnullor containsnullIllegalArgumentException- ifframeUpdatePointscontains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint), or ifframeInterceptPointscontains more than one entry for the same identifier (className/methodId/continuationPoint)
-
-
Method Details
-
read
Deserializes aCoroutineRunnerobject 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:
datadeserialized to aCoroutineRunnerobject- Throws:
NullPointerException- if any argument isnullIllegalArgumentException- 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.FrameUpdatePointwas provided to this class's constructor to handle the changes)
-
reconstruct
Reconstructs aCoroutineRunnerobject from a serializable state.- Parameters:
state- serialized state to reconstruct- Returns:
- reconstructed
CoroutineRunner - Throws:
NullPointerException- if any argument isnullIllegalArgumentException- ifstatecontains 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.FrameUpdatePointwas provided to this class's constructor to handle the changes)
-
placeContinuationReferences
private void placeContinuationReferences(int[] continuationIndexes, Object[] objects, Continuation cn)
-