Package com.offbynull.coroutines.user
Class CoroutineWriter
- java.lang.Object
-
- com.offbynull.coroutines.user.CoroutineWriter
-
public final class CoroutineWriter extends java.lang.ObjectWrites out (serializes) the current state of aCoroutineRunnerobject.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCoroutineWriter.CoroutineSerializerCoroutine serializer.static classCoroutineWriter.DefaultCoroutineSerializerDefault implementation ofCoroutineWriter.CoroutineSerializer(uses Java's built-in serialization mechanism).
-
Field Summary
Fields Modifier and Type Field Description private java.util.MapinterceptersMapprivate CoroutineWriter.CoroutineSerializerserializerprivate java.util.MapupdatersMap
-
Constructor Summary
Constructors Constructor Description CoroutineWriter()Construct aCoroutineWriterobject.CoroutineWriter(CoroutineWriter.CoroutineSerializer serializer, SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints)Constructs aCoroutineWriterobject.CoroutineWriter(SerializedState.FrameInterceptPoint[] frameInterceptPoints)Constructs aCoroutineWriter.CoroutineWriter(SerializedState.FrameUpdatePoint[] frameUpdatePoints)Constructs aCoroutineWriter.CoroutineWriter(SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints)Constructs aCoroutineWriter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int[]clearContinuationReferences(java.lang.Object[] objects, Continuation cn)SerializedStatedeconstruct(CoroutineRunner runner)Deconstructs aCoroutineRunnerobject to a serializable state.byte[]write(CoroutineRunner runner)Serializes aCoroutineRunnerobject as a byte array.
-
-
-
Field Detail
-
serializer
private final CoroutineWriter.CoroutineSerializer serializer
-
updatersMap
private final java.util.Map updatersMap
-
interceptersMap
private final java.util.Map interceptersMap
-
-
Constructor Detail
-
CoroutineWriter
public CoroutineWriter()
Construct aCoroutineWriterobject. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), new FrameUpdatePoint[0], new FrameInterceptPoint[0]).
-
CoroutineWriter
public CoroutineWriter(SerializedState.FrameUpdatePoint[] frameUpdatePoints)
Constructs aCoroutineWriter. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), 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
-
CoroutineWriter
public CoroutineWriter(SerializedState.FrameInterceptPoint[] frameInterceptPoints)
Constructs aCoroutineWriter. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), 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
-
CoroutineWriter
public CoroutineWriter(SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints)
Constructs aCoroutineWriter. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), 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
-
CoroutineWriter
public CoroutineWriter(CoroutineWriter.CoroutineSerializer serializer, SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints)
Constructs aCoroutineWriterobject.- Parameters:
serializer- serializer 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
-
write
public byte[] write(CoroutineRunner runner)
Serializes aCoroutineRunnerobject as a byte array.- Parameters:
runner- coroutine runner to serialize- Returns:
runnerserialized to byte array- Throws:
java.lang.NullPointerException- if any argument isnulljava.lang.IllegalArgumentException- if failed to serialize
-
deconstruct
public SerializedState deconstruct(CoroutineRunner runner)
Deconstructs aCoroutineRunnerobject to a serializable state.- Parameters:
runner- coroutine runner to deconstruct- Returns:
- deconstructed representation of
CoroutineRunner - Throws:
java.lang.NullPointerException- if any argument isnulljava.lang.IllegalArgumentException- if failed to deconstruct
-
clearContinuationReferences
private int[] clearContinuationReferences(java.lang.Object[] objects, Continuation cn)
-
-