Package com.offbynull.coroutines.user
Class CoroutineWriter
java.lang.Object
com.offbynull.coroutines.user.CoroutineWriter
Writes out (serializes) the current state of a
CoroutineRunner object.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCoroutine serializer.static final classDefault implementation ofCoroutineWriter.CoroutineSerializer(uses Java's built-in serialization mechanism). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Mapprivate final CoroutineWriter.CoroutineSerializerprivate final Map -
Constructor Summary
ConstructorsConstructorDescriptionConstruct 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
Modifier and TypeMethodDescriptionprivate int[]clearContinuationReferences(Object[] objects, Continuation cn) deconstruct(CoroutineRunner runner) Deconstructs aCoroutineRunnerobject to a serializable state.byte[]write(CoroutineRunner runner) Serializes aCoroutineRunnerobject as a byte array.
-
Field Details
-
serializer
-
updatersMap
-
interceptersMap
-
-
Constructor Details
-
CoroutineWriter
public CoroutineWriter()Construct aCoroutineWriterobject. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), new FrameUpdatePoint[0], new FrameInterceptPoint[0]). -
CoroutineWriter
Constructs aCoroutineWriter. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), 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
-
CoroutineWriter
Constructs aCoroutineWriter. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), 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
-
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:
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
-
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:
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
-
write
Serializes aCoroutineRunnerobject as a byte array.- Parameters:
runner- coroutine runner to serialize- Returns:
runnerserialized to byte array- Throws:
NullPointerException- if any argument isnullIllegalArgumentException- if failed to serialize
-
deconstruct
Deconstructs aCoroutineRunnerobject to a serializable state.- Parameters:
runner- coroutine runner to deconstruct- Returns:
- deconstructed representation of
CoroutineRunner - Throws:
NullPointerException- if any argument isnullIllegalArgumentException- if failed to deconstruct
-
clearContinuationReferences
-