Package com.offbynull.coroutines.user
Class CoroutineReader
- java.lang.Object
-
- com.offbynull.coroutines.user.CoroutineReader
-
public final class CoroutineReader extends java.lang.ObjectReads in (deserializes) the state of aCoroutineRunnerobject.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCoroutineReader.CoroutineDeserializerCoroutine deserializer.static classCoroutineReader.DefaultCoroutineDeserializerDefault implementation ofCoroutineReader.CoroutineDeserializer(uses Java's built-in serialization mechanism).
-
Field Summary
Fields Modifier and Type Field Description private CoroutineReader.CoroutineDeserializerdeserializerprivate java.util.MapinterceptersMapprivate java.util.MapupdatersMap
-
Constructor Summary
Constructors Constructor Description CoroutineReader()Construct 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidplaceContinuationReferences(int[] continuationIndexes, java.lang.Object[] objects, Continuation cn)CoroutineRunnerread(byte[] data)Deserializes aCoroutineRunnerobject from a byte array.CoroutineRunnerreconstruct(SerializedState state)Reconstructs aCoroutineRunnerobject from a serializable state.
-
-
-
Field Detail
-
deserializer
private final CoroutineReader.CoroutineDeserializer deserializer
-
updatersMap
private final java.util.Map updatersMap
-
interceptersMap
private final java.util.Map interceptersMap
-
-
Constructor Detail
-
CoroutineReader
public CoroutineReader()
Construct aCoroutineReaderobject. Equivalent to callingnew CoroutineReader(new DefaultCoroutineDeserializer(), new FrameUpdatePoint[0], new FrameInterceptPoint[0]).
-
CoroutineReader
public CoroutineReader(SerializedState.FrameUpdatePoint[] frameUpdatePoints)
Constructs aCoroutineReader. Equivalent to callingnew CoroutineReader(new DefaultCoroutineDeserializer(), frameUpdatePoints, new FrameInterceptPoint[0]).- Parameters:
frameUpdatePoints- frame update points- Throws:
java.lang.IllegalArgumentException- ifframeUpdatePointscontains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint)java.lang.NullPointerException- if any argument isnull
-
CoroutineReader
public CoroutineReader(SerializedState.FrameInterceptPoint[] frameInterceptPoints)
Constructs aCoroutineReader. Equivalent to callingnew CoroutineReader(new DefaultCoroutineDeserializer(), new FrameUpdatePoint[0], frameInterceptPoints).- Parameters:
frameInterceptPoints- frame intercept points- Throws:
java.lang.IllegalArgumentException- ifframeInterceptPointscontains more than one entry for the same identifier (className/methodId/continuationPoint)java.lang.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:
java.lang.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)java.lang.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:
java.lang.NullPointerException- if any argument isnullor containsnulljava.lang.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)
-
-
Method Detail
-
read
public CoroutineRunner read(byte[] data)
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:
java.lang.NullPointerException- if any argument isnulljava.lang.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.FrameUpdatePointwas provided to this class's constructor to handle the changes)
-
reconstruct
public CoroutineRunner reconstruct(SerializedState state)
Reconstructs aCoroutineRunnerobject from a serializable state.- Parameters:
state- serialized state to reconstruct- Returns:
- reconstructed
CoroutineRunner - Throws:
java.lang.NullPointerException- if any argument isnulljava.lang.IllegalArgumentException- 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, java.lang.Object[] objects, Continuation cn)
-
-