Package com.offbynull.coroutines.user
Class CoroutineReader
- java.lang.Object
-
- com.offbynull.coroutines.user.CoroutineReader
-
public final class CoroutineReader extends java.lang.Object
Reads in (deserializes) the state of aCoroutineRunner
object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CoroutineReader.CoroutineDeserializer
Coroutine deserializer.static class
CoroutineReader.DefaultCoroutineDeserializer
Default implementation ofCoroutineReader.CoroutineDeserializer
(uses Java's built-in serialization mechanism).
-
Field Summary
Fields Modifier and Type Field Description private CoroutineReader.CoroutineDeserializer
deserializer
private java.util.Map
interceptersMap
private java.util.Map
updatersMap
-
Constructor Summary
Constructors Constructor Description CoroutineReader()
Construct 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
placeContinuationReferences(int[] continuationIndexes, java.lang.Object[] objects, Continuation cn)
CoroutineRunner
read(byte[] data)
Deserializes aCoroutineRunner
object from a byte array.CoroutineRunner
reconstruct(SerializedState state)
Reconstructs aCoroutineRunner
object 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 aCoroutineReader
object. 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
- ifframeUpdatePoints
contains 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
- ifframeInterceptPoints
contains 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
- 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)java.lang.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:
java.lang.NullPointerException
- if any argument isnull
or containsnull
java.lang.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 Detail
-
read
public CoroutineRunner read(byte[] data)
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:
java.lang.NullPointerException
- if any argument isnull
java.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.FrameUpdatePoint
was provided to this class's constructor to handle the changes)
-
reconstruct
public CoroutineRunner reconstruct(SerializedState state)
Reconstructs aCoroutineRunner
object from a serializable state.- Parameters:
state
- serialized state to reconstruct- Returns:
- reconstructed
CoroutineRunner
- Throws:
java.lang.NullPointerException
- if any argument isnull
java.lang.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, java.lang.Object[] objects, Continuation cn)
-
-